[6.4.0][Feat]新增语音打断的回调

This commit is contained in:
chenfufeng
2024-05-20 20:05:21 +08:00
parent 3f467b4f7a
commit a338d92bc8
3 changed files with 12 additions and 3 deletions

View File

@@ -74,6 +74,9 @@ interface IMogoTTSCallback {
default void onSpeakEnd( String speakText ) {
}
default void onStopTts( String speakText ) {
}
default void onSpeakError( String speakText, String errorMsg) {
}

View File

@@ -156,7 +156,7 @@ class IFlyTekTts : IMogoTTS, InitListener {
curTtsEntity?.let {
val string = it.toString()
if (speakVoiceMap.containsKey(string)) {
speakVoiceMap.remove(string)
speakVoiceMap.remove(string)?.onStopTts(string)
}
curTtsEntity = null
}

View File

@@ -357,7 +357,10 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack {
public void stopSpeakTts(String text) {
if (mEngine != null && mHasAuth) {
mSpeakVoiceMap.remove(text);
IMogoTTSCallback callBack = mSpeakVoiceMap.remove(text);
if (callBack != null) {
callBack.onStopTts(curTtsContent);
}
curTtsContent = "";
curTtsLevel = -1;
mEngine.stop();
@@ -366,7 +369,10 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack {
public void stopTts() {
if (mEngine != null && mHasAuth) {
mSpeakVoiceMap.remove(curTtsContent);
IMogoTTSCallback callBack = mSpeakVoiceMap.remove(curTtsContent);
if (callBack != null) {
callBack.onStopTts(curTtsContent);
}
// tts过程中调用stop不会有回调事件
curTtsContent = "";
curTtsLevel = -1;