[bugfix] can not read the last sentence
This commit is contained in:
@@ -62,6 +62,7 @@ class ChatSseService {
|
||||
if (line.startsWith('data:')) {
|
||||
final jsonStr = line.substring(5).trim();
|
||||
if (jsonStr == '[DONE]' || jsonStr.contains('message_end')) {
|
||||
TtsUtil.complete();
|
||||
onStreamResponse(messageId, responseText, true);
|
||||
break;
|
||||
}
|
||||
@@ -89,8 +90,8 @@ class ChatSseService {
|
||||
await _startTtsFuture;
|
||||
_isFirstData = false;
|
||||
}
|
||||
print("----------------------Send text: " + completeText);
|
||||
completeText += isChinese ? ',' : ',';
|
||||
print("----------------------Send text: " + completeText);
|
||||
TtsUtil.send(completeText);
|
||||
}
|
||||
tempText = tempText.substring(endIndex).trim();
|
||||
@@ -108,6 +109,7 @@ class ChatSseService {
|
||||
} catch (e) {
|
||||
// todo
|
||||
} finally {
|
||||
print("------------------------------finally");
|
||||
resetRequest();
|
||||
}
|
||||
}
|
||||
@@ -123,7 +125,7 @@ class ChatSseService {
|
||||
|
||||
Future<void> abort() async {
|
||||
_isAborted = true;
|
||||
TtsUtil.stopTts();
|
||||
TtsUtil.stop();
|
||||
resetRequest();
|
||||
}
|
||||
|
||||
@@ -136,6 +138,7 @@ class ChatSseService {
|
||||
_currentResponse = null;
|
||||
_isFirstData = true;
|
||||
_isTtsStarted = false;
|
||||
_startTtsFuture = null;
|
||||
}
|
||||
|
||||
int _getCompleteTextEndIndex(String buffer) {
|
||||
|
||||
Reference in New Issue
Block a user