[update] use aliyun andriod sdk
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ai_chat_assistant/utils/common_util.dart';
|
||||
import 'package:ai_chat_assistant/utils/tts_util.dart';
|
||||
import 'package:basic_intl/intl.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@@ -15,7 +16,6 @@ import '../services/classification_service.dart';
|
||||
import '../services/control_recognition_service.dart';
|
||||
import '../services/audio_recorder_service.dart';
|
||||
import '../services/voice_recognition_service.dart';
|
||||
import '../services/tts_service.dart';
|
||||
import 'command_service.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
@@ -213,10 +213,11 @@ class MessageService extends ChangeNotifier {
|
||||
id: _latestAssistantMessageId!,
|
||||
text: vehicleCommandResponse.tips!,
|
||||
status: MessageStatus.executing);
|
||||
// if (!_isReplyAborted) {
|
||||
// _ttsService.pushTextForStreamTTS(vehicleCommandResponse.tips!);
|
||||
// _ttsService.markSSEStreamCompleted();
|
||||
// }
|
||||
if (!_isReplyAborted) {
|
||||
if (await TtsUtil.start(isChinese) == true) {
|
||||
TtsUtil.send(vehicleCommandResponse.tips!);
|
||||
}
|
||||
}
|
||||
bool containOpenAC = false;
|
||||
for (var command in vehicleCommandResponse.commands) {
|
||||
if (_isReplyAborted) {
|
||||
@@ -309,6 +310,7 @@ class MessageService extends ChangeNotifier {
|
||||
_chatSseService.request(
|
||||
messageId: _latestAssistantMessageId!,
|
||||
text: text,
|
||||
isChinese: isChinese,
|
||||
onStreamResponse: handleStreamResponse,
|
||||
);
|
||||
}
|
||||
@@ -325,26 +327,18 @@ class MessageService extends ChangeNotifier {
|
||||
status: MessageStatus.normal);
|
||||
}
|
||||
|
||||
void handleStreamResponse(String messageId, String responseText,
|
||||
String completeText, bool isComplete) {
|
||||
void handleStreamResponse(String messageId, String responseText, bool isComplete) {
|
||||
if (_isReplyAborted) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (isComplete) {
|
||||
// if (completeText.isNotEmpty) {
|
||||
// _ttsService.pushTextForStreamTTS(completeText);
|
||||
// }
|
||||
// _ttsService.markSSEStreamCompleted();
|
||||
replaceMessage(
|
||||
id: messageId,
|
||||
text: responseText,
|
||||
status: MessageStatus.completed,
|
||||
);
|
||||
} else {
|
||||
// if (completeText.isNotEmpty) {
|
||||
// _ttsService.pushTextForStreamTTS(completeText);
|
||||
// }
|
||||
replaceMessage(
|
||||
id: messageId, text: responseText, status: MessageStatus.thinking);
|
||||
}
|
||||
@@ -355,7 +349,6 @@ class MessageService extends ChangeNotifier {
|
||||
|
||||
Future<void> abortReply() async {
|
||||
_isReplyAborted = true;
|
||||
// _ttsService.stop();
|
||||
_chatSseService.abort();
|
||||
int index = findMessageIndexById(_latestAssistantMessageId);
|
||||
if (index == -1 || messages[index].status != MessageStatus.thinking) {
|
||||
|
||||
Reference in New Issue
Block a user