0

最初:このAPIを使用した連続音声認識ストリーミングでは、65秒の制限があります。私の目標は、それらの65秒を延長しないことです。 私のアプリ: これはGoogleのストリーミング音声認識を使用しています。私のコードはこの例に基づいています:https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech アプリはかなりうまく動作し、ASRの結果を得て、ユーザーが話すときに画面に表示します。AndroidのGoogle音声クラウドエラー:OUT_OF_RANGE:許可されたストリームの最大再生時間を65秒超過

問題: 私の問題は、いくつかの私のアプリにASRボタンをタップ停止し、ASR SpeechServiceを再起動した後に来るには少し信頼できないです。 SpeechServiceは、いくつかの停止後に正常にシャットダウンされなかったかのように、...

io.grpc.StatusRuntimeException: OUT_OF_RANGE: Exceeded maximum allowed stream duration of 65 seconds. 

サイクルを再起動します。最終的に、私はこのエラーを取得します。

私のコード: 私はこのようなコードを停止します。私は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秒の制限のエラーを回避するために、適切にサービスを停止していますか?どんな勧告?私はfinishRecognizingを(追加することによって、それを解決するために管理し

+0

私は同じ問題に直面しています。あなたは最終的に何かを見つけましたか? – Frank

+0

@Frankまだ!私はこの65秒の問題のいくつかのアイデアを思いつきながら、より簡単なバグを解決しています。あなたが何かを発見したら教えてください、私もそうです! – Josh

答えて

0

)streamObserverからOnNext()メソッド内:

public void onNext(StreamingRecognizeResponse response) { 
      String text = null; 
      boolean isFinal = false; 
      if (response.getResultsCount() > 0) { 
       final StreamingRecognitionResult result = response.getResults(0); 
       isFinal = result.getIsFinal(); 
       if (result.getAlternativesCount() > 0) { 
        final SpeechRecognitionAlternative alternative = result.getAlternatives(0); 
        text = alternative.getTranscript(); 
       } 
      } 
      if (text != null) { 
       for (Listener listener : mListeners) { 
        listener.onSpeechRecognized(text, isFinal); 
       } 
       if(isFinal) 
       { 
        finishRecognizing(); 
       } 
      } 
     } 
関連する問題