Files
ai_chat_assistant/lib/utils/tts_util.dart

24 lines
589 B
Dart

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});
}
static Future<void> stopTts() async {
await execute('stop');
}
}