2025-08-15 09:37:53 +08:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
|
|
class TtsUtil {
|
|
|
|
|
static const MethodChannel _channel =
|
|
|
|
|
MethodChannel('com.example.ai_chat_assistant/tts');
|
|
|
|
|
|
|
|
|
|
static Future<T?> execute<T>(String method,
|
|
|
|
|
[Map<Object, Object>? arguments]) {
|
|
|
|
|
return _channel.invokeMethod(method, arguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Future<bool> start(bool isChinese) async {
|
|
|
|
|
return await execute('start', {'isChinese': isChinese});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Future<void> send(String text) async {
|
|
|
|
|
await execute('send', {'text': text});
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-18 16:30:53 +08:00
|
|
|
static Future<void> complete() async {
|
|
|
|
|
await execute('complete');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Future<void> stop() async {
|
2025-08-15 09:37:53 +08:00
|
|
|
await execute('stop');
|
|
|
|
|
}
|
|
|
|
|
}
|