Google Speech API doesn't transcribe a .flac audio file in Android App





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















private void processSpeech( String data ) throws IOException
{
Speech speechService = new Speech
.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setSpeechRequestInitializer( new SpeechRequestInitializer( CLOUD_API_KEY ) )
.build();

RecognitionConfig recognitionConfig = new RecognitionConfig();
recognitionConfig.setLanguageCode( "en-US" );

RecognitionAudio recognitionAudio = new RecognitionAudio();
recognitionAudio.setContent( data );

SyncRecognizeRequest request = new SyncRecognizeRequest();
request.setConfig( recognitionConfig );
request.setAudio( recognitionAudio );

SyncRecognizeResponse response = speechService.speech()
.syncrecognize( request ).execute();

TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Hello" );

SpeechRecognitionResult result = response.getResults().get( 0 );

final String transcript = result.getAlternatives().get( 0 ).getTranscript();

runOnUiThread( new Runnable()
{
@Override
public void run()
{
TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Heyyy" );
}
} );

}


I used the code for the Google Speech API as mentioned on this GitHub page.



The app does not show any compile time errors but when I run it and choose a .FLAC file to transcribe - nothing happens. After putting print statements within the code I seem to have narrowed down on the error which lies in the following line :-



SyncRecognizeResponse response = speechService.speech().syncrecognize(request).execute();


I don't see any error so I am unable to debug this. Logcat also doesn't show much except "Couldn't load memtrack module". Any suggestions on what has gone wrong?










share|improve this question

























  • The project you linked to is over a year old. That projects imports of import com.google.api.services.speech.v1beta1.* don't match up with the sample Google provides: import com.google.cloud.speech.v1p1beta1.* at cloud.google.com/speech-to-text/docs/reference/libraries as that old project is using a depreciated API.

    – Morrison Chang
    Nov 24 '18 at 19:35




















0















private void processSpeech( String data ) throws IOException
{
Speech speechService = new Speech
.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setSpeechRequestInitializer( new SpeechRequestInitializer( CLOUD_API_KEY ) )
.build();

RecognitionConfig recognitionConfig = new RecognitionConfig();
recognitionConfig.setLanguageCode( "en-US" );

RecognitionAudio recognitionAudio = new RecognitionAudio();
recognitionAudio.setContent( data );

SyncRecognizeRequest request = new SyncRecognizeRequest();
request.setConfig( recognitionConfig );
request.setAudio( recognitionAudio );

SyncRecognizeResponse response = speechService.speech()
.syncrecognize( request ).execute();

TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Hello" );

SpeechRecognitionResult result = response.getResults().get( 0 );

final String transcript = result.getAlternatives().get( 0 ).getTranscript();

runOnUiThread( new Runnable()
{
@Override
public void run()
{
TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Heyyy" );
}
} );

}


I used the code for the Google Speech API as mentioned on this GitHub page.



The app does not show any compile time errors but when I run it and choose a .FLAC file to transcribe - nothing happens. After putting print statements within the code I seem to have narrowed down on the error which lies in the following line :-



SyncRecognizeResponse response = speechService.speech().syncrecognize(request).execute();


I don't see any error so I am unable to debug this. Logcat also doesn't show much except "Couldn't load memtrack module". Any suggestions on what has gone wrong?










share|improve this question

























  • The project you linked to is over a year old. That projects imports of import com.google.api.services.speech.v1beta1.* don't match up with the sample Google provides: import com.google.cloud.speech.v1p1beta1.* at cloud.google.com/speech-to-text/docs/reference/libraries as that old project is using a depreciated API.

    – Morrison Chang
    Nov 24 '18 at 19:35
















0












0








0








private void processSpeech( String data ) throws IOException
{
Speech speechService = new Speech
.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setSpeechRequestInitializer( new SpeechRequestInitializer( CLOUD_API_KEY ) )
.build();

RecognitionConfig recognitionConfig = new RecognitionConfig();
recognitionConfig.setLanguageCode( "en-US" );

RecognitionAudio recognitionAudio = new RecognitionAudio();
recognitionAudio.setContent( data );

SyncRecognizeRequest request = new SyncRecognizeRequest();
request.setConfig( recognitionConfig );
request.setAudio( recognitionAudio );

SyncRecognizeResponse response = speechService.speech()
.syncrecognize( request ).execute();

TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Hello" );

SpeechRecognitionResult result = response.getResults().get( 0 );

final String transcript = result.getAlternatives().get( 0 ).getTranscript();

runOnUiThread( new Runnable()
{
@Override
public void run()
{
TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Heyyy" );
}
} );

}


I used the code for the Google Speech API as mentioned on this GitHub page.



The app does not show any compile time errors but when I run it and choose a .FLAC file to transcribe - nothing happens. After putting print statements within the code I seem to have narrowed down on the error which lies in the following line :-



SyncRecognizeResponse response = speechService.speech().syncrecognize(request).execute();


I don't see any error so I am unable to debug this. Logcat also doesn't show much except "Couldn't load memtrack module". Any suggestions on what has gone wrong?










share|improve this question
















private void processSpeech( String data ) throws IOException
{
Speech speechService = new Speech
.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setSpeechRequestInitializer( new SpeechRequestInitializer( CLOUD_API_KEY ) )
.build();

RecognitionConfig recognitionConfig = new RecognitionConfig();
recognitionConfig.setLanguageCode( "en-US" );

RecognitionAudio recognitionAudio = new RecognitionAudio();
recognitionAudio.setContent( data );

SyncRecognizeRequest request = new SyncRecognizeRequest();
request.setConfig( recognitionConfig );
request.setAudio( recognitionAudio );

SyncRecognizeResponse response = speechService.speech()
.syncrecognize( request ).execute();

TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Hello" );

SpeechRecognitionResult result = response.getResults().get( 0 );

final String transcript = result.getAlternatives().get( 0 ).getTranscript();

runOnUiThread( new Runnable()
{
@Override
public void run()
{
TextView speechToTextResult = ( TextView ) findViewById( R.id.speech_to_text_result );
speechToTextResult.setText( "Heyyy" );
}
} );

}


I used the code for the Google Speech API as mentioned on this GitHub page.



The app does not show any compile time errors but when I run it and choose a .FLAC file to transcribe - nothing happens. After putting print statements within the code I seem to have narrowed down on the error which lies in the following line :-



SyncRecognizeResponse response = speechService.speech().syncrecognize(request).execute();


I don't see any error so I am unable to debug this. Logcat also doesn't show much except "Couldn't load memtrack module". Any suggestions on what has gone wrong?







java android google-api google-speech-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 19:05









Federico Grandi

3,31331230




3,31331230










asked Nov 24 '18 at 17:28









DSSDSS

11




11













  • The project you linked to is over a year old. That projects imports of import com.google.api.services.speech.v1beta1.* don't match up with the sample Google provides: import com.google.cloud.speech.v1p1beta1.* at cloud.google.com/speech-to-text/docs/reference/libraries as that old project is using a depreciated API.

    – Morrison Chang
    Nov 24 '18 at 19:35





















  • The project you linked to is over a year old. That projects imports of import com.google.api.services.speech.v1beta1.* don't match up with the sample Google provides: import com.google.cloud.speech.v1p1beta1.* at cloud.google.com/speech-to-text/docs/reference/libraries as that old project is using a depreciated API.

    – Morrison Chang
    Nov 24 '18 at 19:35



















The project you linked to is over a year old. That projects imports of import com.google.api.services.speech.v1beta1.* don't match up with the sample Google provides: import com.google.cloud.speech.v1p1beta1.* at cloud.google.com/speech-to-text/docs/reference/libraries as that old project is using a depreciated API.

– Morrison Chang
Nov 24 '18 at 19:35







The project you linked to is over a year old. That projects imports of import com.google.api.services.speech.v1beta1.* don't match up with the sample Google provides: import com.google.cloud.speech.v1p1beta1.* at cloud.google.com/speech-to-text/docs/reference/libraries as that old project is using a depreciated API.

– Morrison Chang
Nov 24 '18 at 19:35














0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460677%2fgoogle-speech-api-doesnt-transcribe-a-flac-audio-file-in-android-app%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460677%2fgoogle-speech-api-doesnt-transcribe-a-flac-audio-file-in-android-app%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()