Files
ai_chat_assistant/lib/utils/tts_util.dart

28 lines
679 B
Dart
Raw Normal View History

2025-08-15 09:37:53 +08:00
import 'package:flutter/services.dart';
class TtsUtil {
static const MethodChannel _channel =
2025-09-17 15:09:05 +08:00
MethodChannel('com.example.ai_chat_assistant/ali_sdk');
2025-08-15 09:37:53 +08:00
static Future<T?> execute<T>(String method,
[Map<Object, Object>? arguments]) {
return _channel.invokeMethod(method, arguments);
}
static Future<bool> start(bool isChinese) async {
2025-08-22 17:35:02 +08:00
return await execute('startTts', {'isChinese': isChinese});
2025-08-15 09:37:53 +08:00
}
static Future<void> send(String text) async {
2025-08-22 17:35:02 +08:00
await execute('sendTts', {'text': text});
2025-08-15 09:37:53 +08:00
}
static Future<void> complete() async {
2025-08-22 17:35:02 +08:00
await execute('completeTts');
}
static Future<void> stop() async {
2025-08-22 17:35:02 +08:00
await execute('stopTts');
2025-08-15 09:37:53 +08:00
}
}