|
|
|
@ -483,6 +483,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
@JavascriptInterface |
|
|
|
public void startRecord() { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:startRecord()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/tts/stop\"}")); |
|
|
|
@ -504,6 +505,9 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
isrun = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
LoggerUtil.e(TAG,e.getMessage()); |
|
|
|
} |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
@ -515,34 +519,48 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
@JavascriptInterface |
|
|
|
public void stopRecord() { |
|
|
|
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(); |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
LoggerUtil.e(TAG,e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// h5调用android:开始合成语音
|
|
|
|
@JavascriptInterface |
|
|
|
public void startTTS(String txt) { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:startTTS()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\": \"/tts/start\",\"params\": {\"text\":\"", txt, "\", \"mode\":\"autoPlay\"}}")); |
|
|
|
}else{ |
|
|
|
ttsUtil.startTTs(txt); |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
LoggerUtil.e(TAG,e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
// h5调用android:停止合成语音
|
|
|
|
@JavascriptInterface |
|
|
|
public void stopTTS() { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:stopTTS()"); |
|
|
|
try{ |
|
|
|
if("sbc".equals(Constant.TTSFac)){ |
|
|
|
if (localSocketClient == null) initLocalSocketClient(); //-------------------------------
|
|
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/tts/stop\"}")); |
|
|
|
}else{ |
|
|
|
ttsUtil.stopTTs(); |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
LoggerUtil.e(TAG,e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
|