|
|
|
@ -86,8 +86,8 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
static final int TYPE_GO_SAVESCREEN = 300;//导视通知跳转屏保
|
|
|
|
static final int TYPE_HINT_PASSWORD = 3;//隐藏密码输入框
|
|
|
|
static final int TYPE_START_SERVER = 4;//重新启动web服务
|
|
|
|
static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 http://192.168.1.218:5173/
|
|
|
|
//static String HtmlUrl = "http://192.168.0.109:5173/";
|
|
|
|
//static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 http://192.168.1.218:5173/
|
|
|
|
static String HtmlUrl = "http://192.168.1.196:5173/"; //"http://192.168.0.109:5173/";
|
|
|
|
int time = 0; |
|
|
|
private VideoView currentVideo; |
|
|
|
private SoundPool soundPool; |
|
|
|
@ -936,6 +936,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
AILocalSignalAndWakeupConfig config = new AILocalSignalAndWakeupConfig(); |
|
|
|
config.setSspeResource("sspe_aec-bf-bss-wkp_ch10-mic8-ref2_outgain4_v2.0.0.165_20251127_v1.bin");//设置SSPE资源
|
|
|
|
config.setEchoChannelNum(2); |
|
|
|
mLocalEngine = AILocalSignalAndWakeupEngine.createInstance(); |
|
|
|
mLocalEngine.init(config, new SSPEListener()); |
|
|
|
|
|
|
|
@ -944,20 +945,22 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
asrconfig.setLocalVadEnable(true); |
|
|
|
asrconfig.setVadResource("vad_aihome_v0.12c_noDither.bin"); |
|
|
|
mEngine = AICloudASREngine.createInstance(); |
|
|
|
mEngine.init(asrconfig, new AIASRListenerImpl()); |
|
|
|
|
|
|
|
aiCloudASRIntent = new AICloudASRIntent(); |
|
|
|
aiCloudASRIntent.setEnablePunctuation(true); |
|
|
|
aiCloudASRIntent.setRealback(true);//打开实时反馈功能
|
|
|
|
aiCloudASRIntent.setCloudVadEnable(false); |
|
|
|
aiCloudASRIntent.setAudioType(AICloudASRIntent.PCM_ENCODE_TYPE.valueOf("WAV")); |
|
|
|
aiCloudASRIntent.setResourceType(Constant.asrModel); |
|
|
|
aiCloudASRIntent.setEnableNumberConvert(true);//设置启用识别结果汉字数字转阿拉伯数字功能
|
|
|
|
aiCloudASRIntent.setWaitingTimeout(30000); //设置等待识别结果超时时长,默认5000ms
|
|
|
|
aiCloudASRIntent.setNoSpeechTimeOut(6000); |
|
|
|
aiCloudASRIntent.setPauseTime(2000); |
|
|
|
//aiCloudASRIntent.setServer("wss://asr.dui.ai/runtime/v2/recognize");
|
|
|
|
mEngine.init(asrconfig, new AIASRListenerImpl()); |
|
|
|
aiCloudASRIntent.setWaitingTimeout(10000); //设置等待识别结果超时时长,默认5000ms
|
|
|
|
aiCloudASRIntent.setNoSpeechTimeOut(5000); |
|
|
|
aiCloudASRIntent.setPauseTime(3000); |
|
|
|
//aiCloudASRIntent.setUseCustomFeed(false); // 设置是否使用外部喂音频
|
|
|
|
} |
|
|
|
|
|
|
|
initRecorder(); |
|
|
|
//initRecorder(); //暂不开
|
|
|
|
} |
|
|
|
|
|
|
|
private void initRecorder() { |
|
|
|
@ -984,104 +987,6 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private class SSPEListener implements AILocalSignalAndWakeupListener { |
|
|
|
@Override |
|
|
|
public void onInit(int resultCode) { |
|
|
|
if (resultCode == AIConstant.OPT_SUCCESS) { |
|
|
|
LoggerUtil.e("setSspeResource:","sspe init success"); |
|
|
|
} else { |
|
|
|
LoggerUtil.e("setSspeResource:","sspe init fail: " + resultCode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError(AIError aiError) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onWakeup(double v, String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onWakeup(String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onNearInformation(String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDoaResult(int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onReadyForSpeech() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRawDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onResultDataReceived(byte[] bytes, int i, int i1) { |
|
|
|
if (mEngine != null) { |
|
|
|
mEngine.feedData(bytes, i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onVprintCutDataReceived(int i, byte[] bytes, int i1) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onAgcDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onInputDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onOutputDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEchoDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onSevcDoaResult(int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onSevcNoiseResult(String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onMultibfDataReceived(byte[] bytes, int i, int i1) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEchoVoipDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private class AIASRListenerImpl implements AIASRListener { |
|
|
|
|
|
|
|
public void onError(AIError error) { |
|
|
|
@ -1173,6 +1078,102 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private class SSPEListener implements AILocalSignalAndWakeupListener { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onInit(int resultCode) { |
|
|
|
if (resultCode == AIConstant.OPT_SUCCESS) { |
|
|
|
LoggerUtil.d("ASRInit: ","sspe init success"); |
|
|
|
} else { |
|
|
|
LoggerUtil.e("ASRInit: ","sspe init fail: " + resultCode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError(AIError error) { |
|
|
|
//74405 唤醒超时
|
|
|
|
LoggerUtil.e("ASRInit: ","sspe onError: " + error); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onWakeup(double confidence, String wakeupword) { |
|
|
|
// LoggerUtil.e("ASRInit: ","onWakeup: " + wakeupword + " " + confidence);
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onWakeup(String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onNearInformation(String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDoaResult(int doa) { |
|
|
|
//LoggerUtil.e("ASRInit: ","doa: " + doa);
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onReadyForSpeech() { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRawDataReceived(byte[] bytes, int size) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onResultDataReceived(byte[] bytes, int size, int wakeupType) { |
|
|
|
if (mEngine != null) { |
|
|
|
mEngine.feedData(bytes, size); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onVprintCutDataReceived(int i, byte[] bytes, int i1) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onAgcDataReceived(byte[] bytes, int i) { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onInputDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onOutputDataReceived(byte[] bytes, int i) { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEchoDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onSevcDoaResult(int i) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onSevcNoiseResult(String s) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onMultibfDataReceived(byte[] data, int size, int index) { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEchoVoipDataReceived(byte[] bytes, int i) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* android调用js:传送识别语音内容 |
|
|
|
*/ |
|
|
|
|