第一条:我已经知道在使用此API进行连续语音识别流时,存在65秒的限制。我的目标不是延长这65秒。 我的应用程序: 它使用谷歌的流语音识别,我基于我的代码在这个例子:https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech 该应用程序工作得很好,我得到ASR结果,并显示在屏幕上,因为用户说话,Siri风格。Android上的Google语音云错误:OUT_OF_RANGE:超过了65秒的最大允许流持续时间
问题: 我的问题来敲打ASR按钮上我的应用程序数,停止和重新启动ASR SpeechService后是有点靠不住。最终,我得到这个错误:
io.grpc.StatusRuntimeException: OUT_OF_RANGE: Exceeded maximum allowed stream duration of 65 seconds.
...好像SpeechService在多次停止,重新启动循环后没有正常关闭。
我的代码: 我停止我这样的代码,我怀疑的地方在我StopStreamingASR方法的实现问题。我在一个单独的线程中运行它,因为我相信它可以提高性能(希望我没有错):
static void StopStreamingASR(){
loge("stopGoogleASR_API");
//stopMicGlow();
//Run on separate thread to keep UI thread light.
Thread thread = new Thread() {
@Override
public void run() {
if(mSpeechService!=null) {
mSpeechService.finishRecognizing();
stopVoiceRecorder();
// Stop Cloud Speech API
if(mServiceConnection!=null) {
try {
app.loge("CAUTION, attempting to stop service");
try {
mSpeechService.removeListener(mSpeechServiceListener);
//original mActivity.unbindService(mServiceConnection);
app.ctx.unbindService(mServiceConnection);
mSpeechService = null;
}
catch(Exception e){
app.loge("Service Shutdown exception: "+e);
}
}
catch(Exception e){
app.loge("CAUTION, attempting to stop service FAILED: "+e.toString());
}
}
}
}
};
thread.start();
}
private static void stopVoiceRecorder() {
loge("stopVoiceRecorder");
if (mVoiceRecorder != null) {
mVoiceRecorder.stop();
mVoiceRecorder = null;
}
}
我是否正确停止服务,以避免65秒的限制错误?任何建议?
我我遇到了同样的问题。你最终找到了什么? – Frank
@Frank还没有!我正在解决一些更简单的错误,同时我想出了这个65秒的问题的一些想法。让我知道如果你发现了什么,我也会! – Josh