feat: 新增ai_chat_core,将core 和 widget 分离(未完成)
迁移了 models enums, utils, http 封装,还有一些extensions;service 只迁移了 sse service
This commit is contained in:
36
lib/services/platform_tts_service.dart
Normal file
36
lib/services/platform_tts_service.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:ai_chat_core/ai_chat_core.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// TtsService 的平台特定实现,通过 MethodChannel 调用原生代码
|
||||
class PlatformTtsService implements TtsService {
|
||||
@override
|
||||
final String channelName;
|
||||
|
||||
final MethodChannel _channel;
|
||||
|
||||
PlatformTtsService(this.channelName): _channel = MethodChannel(channelName);
|
||||
|
||||
Future<T?> _execute<T>(String method, [Map<Object, Object>? arguments]) {
|
||||
return _channel.invokeMethod(method, arguments);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> start(bool isChinese) async {
|
||||
return await _execute('startTts', {'isChinese': isChinese}) ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> send(String text) async {
|
||||
await _execute('sendTts', {'text': text});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> complete() async {
|
||||
await _execute('completeTts');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> stop() async {
|
||||
await _execute('stopTts');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user