|
|
|
@ -661,7 +661,6 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:startRecord()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/tts/stop\"}")); |
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/asr/start\"}")); |
|
|
|
}else{ |
|
|
|
@ -697,7 +696,6 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:stopRecord()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/asr/stop\"}")); |
|
|
|
}else{ |
|
|
|
stopAsr(); |
|
|
|
@ -713,7 +711,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:startTTS()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
if (localSocketClient == null) connectLocalSocket(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\": \"/tts/start\",\"params\": {\"text\":\"", txt, "\", \"mode\":\"autoPlay\"}}")); |
|
|
|
}else{ |
|
|
|
ttsUtil.startTTs(txt); |
|
|
|
@ -728,7 +726,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:stopTTS()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)){ |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
if (localSocketClient == null) connectLocalSocket(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/tts/stop\"}")); |
|
|
|
}else{ |
|
|
|
ttsUtil.stopTTs(); |
|
|
|
@ -853,7 +851,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEndOfSpeech() { |
|
|
|
Log.d(TAG, "结束说话"); |
|
|
|
LoggerUtil.e("onEndOfSpeech:", "window.youAskOver('');"); |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
@ -915,7 +913,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
localSocketClient.reconnect(); |
|
|
|
} |
|
|
|
} catch (Throwable t) { |
|
|
|
LoggerUtil.e("connectLocalSocket", StringUtil.getThrowableStr(t)); |
|
|
|
LoggerUtil.e("connectLocalSocket: Throwable", StringUtil.getThrowableStr(t)); |
|
|
|
destroyLocalSocketClient(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -961,6 +959,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
}); |
|
|
|
} |
|
|
|
}else if("hardware.status".equals(method)){ // 网络变化
|
|
|
|
LoggerUtil.e("ttsSocket: hardware.status", content.getNetwork().trim()); |
|
|
|
if("lan".equals(content.getNetwork().trim())) { // 网络断开
|
|
|
|
destroyLocalSocketClient(); |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@ -971,7 +970,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
}); |
|
|
|
}else{ |
|
|
|
destroyLocalSocketClient(); |
|
|
|
initLocalSocketClient(); |
|
|
|
connectLocalSocket(); |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
@ -988,7 +987,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
localSocketClient.setOnCloseListener((code, reason, remote) -> { |
|
|
|
LoggerUtil.e("LocSocCliManager", "onClose:code="+code); |
|
|
|
destroyLocalSocketClient(); |
|
|
|
initLocalSocketClient(); |
|
|
|
connectLocalSocket(); |
|
|
|
}); |
|
|
|
localSocketClient.setOnErrorListener((ex) -> { |
|
|
|
LoggerUtil.e("LocSocCliManager", "onError"); |
|
|
|
|