0
votes

I want to convert recorded audio files speech to text. I'm trying to use Google Speech API using Asynchronous Speech Recognition.

I have few question on how to proceed.

1 . I want to convert audio text and don't want it in real-time. So I should use Asynchronous recgonition ?
Google sample project uses SpeechGrpc. Is it necessary to use in android ASychronous speech recognition? Or I can use SpeechClient After authentication ..How?

2 . SpeechGrpc (com.google.cloud.speech.v1.SpeechGrpc) is not present in my package ! (com.google.cloud.speech.v1). I'll have to install it from here? grpc.io

3 . I used Google Cloud Platform Console API key to authenticate to the Speech API (ManagedChannel object) but I cant understand how to use it and which function to use for Asynchronous Speech Recognition.

// Authentication 

try {
                GoogleCredentials creds = GoogleCredentials.fromStream(stream);
                creds = creds.createScoped(SCOPE);
                mChannel = ManagedChannelBuilder.forAddress(HOSTNAME, PORT)
                        .intercept(new ClientAuthInterceptor(creds, Executors.newSingleThreadExecutor()))
                        .build();
            }catch (IOException e){
                Log.e(TAG, "Failed to create channel.", e);
            }

So what should I do after authentication. Is there any code reference or documentation for Asynchronous Speech Recognition in android.

1

1 Answers

0
votes

Yes you would need to use Asynchronous request.

You need to upload files to google cloud storage if they are longer than a minute. https://cloud.google.com/speech/quotas "* Audio longer than ~1 minute must use the uri field to reference an audio file in Google Cloud Storage."

I use the implementation on the sample project and it works pretty well, i would recommend using SpeechGrpc with longRunningRecognize for the request.

You can use the json credential file if using SpeechGrpc by reading the file stream and then using GoogleCredentials to authenticate.