|
|
|
@ -5,6 +5,7 @@ import 'package:deep_voice/data/services/spotify_service.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:flutter/widgets.dart'; |
|
|
|
import 'package:get_storage/get_storage.dart'; |
|
|
|
import 'package:haptic_feedback/haptic_feedback.dart'; |
|
|
|
import 'package:just_audio/just_audio.dart'; |
|
|
|
import 'package:chat_storage/chat_storage.dart'; |
|
|
|
import 'package:path/path.dart'; |
|
|
|
@ -604,6 +605,7 @@ class ChatController extends GetxController { |
|
|
|
isHoldSpeak.value = true; |
|
|
|
recognizedText.value = ''; |
|
|
|
finalResult = ''; |
|
|
|
Haptics.vibrate(HapticsType.success); |
|
|
|
|
|
|
|
// 监听识别事件 |
|
|
|
_recognitionSubscription = recognitionStream.listen( |
|
|
|
@ -626,13 +628,16 @@ class ChatController extends GetxController { |
|
|
|
_recognitionSubscription?.cancel(); |
|
|
|
_recognitionSubscription = null; |
|
|
|
|
|
|
|
String sendText = ''; |
|
|
|
|
|
|
|
final intermediateIndex = |
|
|
|
messages.indexWhere((m) => m.isIntermediate && m.role == 'user'); |
|
|
|
if (intermediateIndex >= 0) { |
|
|
|
sendText = messages[intermediateIndex].content; |
|
|
|
messages.removeAt(intermediateIndex); |
|
|
|
} |
|
|
|
|
|
|
|
sendMessage(finalResult); |
|
|
|
sendMessage(sendText); |
|
|
|
|
|
|
|
recognizedText.value = ''; |
|
|
|
finalResult = ''; |
|
|
|
|