2017-11-21 10 views
0

Google 음성 API를 Android에서 실행하려고합니다. 파일을로드하고 텍스트로 변환 할 때 비동기 메서드를 사용하고 싶습니다. recgognize()는 '치명적인 오류'가 발생 호출에치명적 외침 - on calls() Google Speech API Android

코드 :

RecognizeResponse response; 
    recognitionConfig = RecognitionConfig.newBuilder() 
      .setLanguageCode("en-US") 
      .setEncoding(RecognitionConfig.AudioEncoding.LINEAR16) 
      .setSampleRateHertz(DEFAULT_SAMPLING_RATE) 
      .build(); 

    try { 
     SpeechGrpc.SpeechBlockingStub speechClient = getSpeechBlockingStub(); 
     RecognitionAudio recognitionAudio = RecognitionAudio 
       .newBuilder() 
       .setContent(audioBytes) 
       .build(); 
     RecognizeRequest request = RecognizeRequest 
       .newBuilder() 
       .setConfig(recognitionConfig) 
       .setAudio(recognitionAudio) 
       .build(); 

     response = speechClient.recognize(request); 

     if ((response.getResultsCount() == 0) || (response.getResults(0).getAlternativesCount() == 0)) { 
      //throw new AIServiceException("No speech"); 
     } 
     String transcript = response.getResults(0).getAlternatives(0).getTranscript(); 

     Toast.makeText(cntxt, transcript, Toast.LENGTH_LONG).show(); 
    } catch (IOException | StatusRuntimeException e) { 
     //throw new AIServiceException("Failed to recognize speech", e); 
    } 

오류 :

FATAL EXCEPTION: main Process: com.inc.pixie.arron, PID: 7938 java.lang.AbstractMethodError: abstract method "java.util.concurrent.ScheduledExecutorService io.grpc.internal.ClientTransportFactory.getScheduledExecutorService()" at io.grpc.internal.CallCredentialsApplyingTransportFactory.getScheduledExecutorService(CallCredentialsApplyingTransportFactory.java:52) at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:557) at io.grpc.auth.ClientAuthInterceptor.interceptCall(ClientAuthInterceptor.java:65) at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104) at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:536) at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:113) at com.google.cloud.speech.v1.SpeechGrpc$SpeechBlockingStub.recognize(SpeechGrpc.java:241) at com.inc.pixie.arron.RecognizeAPI.voiceRequest(RecognizeAPI.java:89) at com.inc.pixie.arron.ConversationActivity.onCreate(ConversationActivity.java:28) at android.app.Activity.performCreate(Activity.java:6674) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2690) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2806) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1540) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6293) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1065) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:926)

에 어떤 문제가 있습니까?

이 평균 무엇을 - 내가 무엇을 볼 수에서 java.lang.AbstractMethodError: abstract method "java.util.concurrent.ScheduledExecutorService io.grpc.internal.ClientTransportFactory.getScheduledExecutorService()"

답변