唤醒流程更新,修复重复唤醒的问题
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:ui';
|
||||
import 'package:ai_chat_assistant/manager.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vosk_wakeword/flutter_vosk_wakeword.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../pages/full_screen.dart';
|
||||
import '../services/message_service.dart';
|
||||
@@ -44,6 +45,7 @@ class _ChatPopupState extends State<ChatPopup> with SingleTickerProviderStateMix
|
||||
|
||||
// 订阅唤醒词事件
|
||||
_wakeWordSubscription = AIChatAssistantManager.instance.onWakeWordDetected.listen((_) async {
|
||||
await FlutterVoskWakeword.instance.stop();
|
||||
// 在这里处理唤醒事件,例如显示聊天窗口
|
||||
debugPrint("唤醒词被检测到,执行UI操作!");
|
||||
final messageService = MessageService.instance;
|
||||
@@ -59,8 +61,9 @@ class _ChatPopupState extends State<ChatPopup> with SingleTickerProviderStateMix
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _insertOverlay() {
|
||||
Future<void> _insertOverlay() async {
|
||||
if (_isShowingPopup) return;
|
||||
await FlutterVoskWakeword.instance.stop(); // 停止唤醒词监听,避免误触发
|
||||
setState(() {
|
||||
_isShowingPopup = true;
|
||||
});
|
||||
@@ -69,6 +72,7 @@ class _ChatPopupState extends State<ChatPopup> with SingleTickerProviderStateMix
|
||||
|
||||
void _removeOverlay() {
|
||||
if (!_isShowingPopup) return;
|
||||
FlutterVoskWakeword.instance.start(); // 重新开始监听唤醒词
|
||||
_partScreenAnimationController.reverse().then((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user