|
|
|
@ -539,14 +539,14 @@ class TranslationController extends GetxController { |
|
|
|
); |
|
|
|
if (currentMode.value == 'faceToFace' && activeSpeaker.value == 0) { |
|
|
|
_asrService.setPause(); |
|
|
|
} else { |
|
|
|
translationHistory.add(newItem); |
|
|
|
translationHistory.refresh(); |
|
|
|
_scrollToBottom(); |
|
|
|
saveTranslationHistory(); |
|
|
|
// 使用新项目的时间戳进行翻译 |
|
|
|
translateText(text, newItem.timestamp, isFinal: true); |
|
|
|
} |
|
|
|
} //else { |
|
|
|
translationHistory.add(newItem); |
|
|
|
translationHistory.refresh(); |
|
|
|
_scrollToBottom(); |
|
|
|
saveTranslationHistory(); |
|
|
|
// 使用新项目的时间戳进行翻译 |
|
|
|
translateText(text, newItem.timestamp, isFinal: true); |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -612,20 +612,20 @@ class TranslationController extends GetxController { |
|
|
|
// 更新后滚动到底部 |
|
|
|
_scrollToBottom(); |
|
|
|
// 播放TTS - 只在最终结果时播放 |
|
|
|
if (isTtsEnabled.value && |
|
|
|
isFinal && |
|
|
|
currentMode.value != 'faceToFace') { |
|
|
|
await playTranslatedText(translationResult); |
|
|
|
} else { |
|
|
|
fTFTranslationResult = |
|
|
|
(fTFTranslationResult ?? '') + translationResult; |
|
|
|
|
|
|
|
if (activeSpeaker.value == 0 && !isPlayback) { |
|
|
|
isPlayback = true; |
|
|
|
await _ttsService.setAudioOutputDevice(lastActiveSpeaker.value); |
|
|
|
await Future.delayed(const Duration(milliseconds: 1300)); |
|
|
|
await playTranslatedText(fTFTranslationResult!); |
|
|
|
fTFTranslationResult = ''; |
|
|
|
if (isFinal) { |
|
|
|
if (isTtsEnabled.value && currentMode.value != 'faceToFace') { |
|
|
|
await playTranslatedText(translationResult); |
|
|
|
} else { |
|
|
|
fTFTranslationResult = |
|
|
|
(fTFTranslationResult ?? '') + translationResult; |
|
|
|
print("translationResult=$translationResult"); |
|
|
|
if (activeSpeaker.value == 0 && !isPlayback) { |
|
|
|
isPlayback = true; |
|
|
|
await _ttsService.setAudioOutputDevice(lastActiveSpeaker.value); |
|
|
|
await Future.delayed(const Duration(milliseconds: 1300)); |
|
|
|
await playTranslatedText(fTFTranslationResult!); |
|
|
|
fTFTranslationResult = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -653,6 +653,7 @@ class TranslationController extends GetxController { |
|
|
|
final voiceName = _languageManager |
|
|
|
.getTtsVoiceNameByAsrCode(detectedTargetLanguageCode) ?? |
|
|
|
'en-US-AriaNeural'; |
|
|
|
print("voiceName=$voiceName,text$text"); |
|
|
|
await _ttsService.setVoice(voiceName); |
|
|
|
await _ttsService.speakOnce(text); |
|
|
|
} catch (e) { |
|
|
|
|