feat: 新增语音唤醒

唤醒的逻辑跟长按的逻辑不一样,不能像之前那样长按图标来录音,结束长按来结束录音
This commit is contained in:
2025-09-26 16:23:48 +08:00
parent 4a41c25502
commit f5699fd144
11 changed files with 247 additions and 13 deletions

View File

@@ -3,6 +3,8 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:ai_chat_assistant/ai_chat_assistant.dart';
import 'pages/home.dart';
class VehicleCommandClent extends VehicleCommandHandler {
@override
AIChatCommandCubit? get commandCubit => super.commandCubit;
@@ -13,7 +15,6 @@ class VehicleCommandClent extends VehicleCommandHandler {
print('执行车控命令: ${command.type}, 参数: ${command.params}');
if (commandCubit != null) {
commandCubit?.emit(AIChatCommandState(
commandId: command.commandId,
commandType: command.type,
@@ -64,6 +65,8 @@ void main() async {
AIChatAssistantManager.instance.setupCommandHandle(commandHandler: VehicleCommandClent());
runApp(const MyApp());
AIChatAssistantManager.instance.setWakeWordDetection(true);
}
class MyApp extends StatelessWidget {
@@ -77,18 +80,7 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const ExampleHomePage(),
);
}
}
class ExampleHomePage extends StatelessWidget {
const ExampleHomePage({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: ChatAssistantApp(),
home: HomePage(),
);
}
}