Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

No results with is_final true for single utterance set to true

I am using below configuration to identify my voice input stream (Hindi language)  :

 
config.set_language_code("hi-IN");
config.set_sample_rate_hertz(8000);
config.set_encoding(RecognitionConfig::LINEAR16);
config.set_model("command_and_search");
streaming_config.set_single_utterance(true);
streaming_config.set_interim_results(true);
 
After setting single utterance to true I am not getting any results with is_final as "True" in the sample application : https://github.com/GoogleCloudPlatform/cpp-samples/blob/main/speech/api/streaming_transcribe.cc 
 
for (auto response = read(); response.has_value(); response = read()) {
// Dump the transcript of all the results.
std::cout<<"Printing speech - event type = "<<response->speech_event_type()<<std::endl;
 
for (auto const& result : response->results()) {
std::cout<<"Is final = "<<result.is_final()<<std::endl;
for (auto const& alternative : result.alternatives()) {
if(!result.is_final())
{
std::cout<<"Interim results ==-========="<<"\t";
std::cout //<< alternative.confidence() << "\t"
<< alternative.transcript() << "\n";
}
else
{
std::cout<<"is_final has returned true"<<"\t";
std::cout //<< alternative.confidence() << "\t"
<< alternative.transcript() << "\n";
}
std::cout<<"Printing speech - event type = "<<response->speech_event_type()<<std::endl;
}
}
}
 
For Hindi inputs like single words :  इस,  21(इक्कीस)
I never get a response with is_final set to true even after getting  response->speech_event_type() as '1' (END_OF_SINGLE_UTTERANCE)
 
 
0 3 836
3 REPLIES 3

Have you confirmed whether changing the set_interim_results() property to `false` changes the output result? Based on the documentation, using false as the argument will only return results with is_final=true.

Thanks for your response.

I do not get any results if I change set_interim_results() property to false

I did get some interim results when the property was set to true and 

speech_event_type() did return 1. Usually, I get response with is_final set to true, but this does not happen in this case . Below is the log from my application when set_interim_results() is set to true :

 

 

 

hlpr_start_stream() ----> !!!!!!!!!!!!!! Vaibhav :: single_utternace :  ======== : 0

2022-10-11 09:24:15:824114 [INFO]    hlpr_start_stream() --> printing results : 0.900000

2022-10-11 09:24:15:824126 [INFO]   hlpr_start_stream() ---> !!!!!!!!!!!!!! inside 2nd if -------------------------------------

2022-10-11 09:24:15:824132 [INFO]    ########## hlpr_start_stream() printing interim results transcript  #####: इस

2022-10-11 09:24:15:824139 [INFO]    hlpr_start_stream() -----Vaibhav :: time_since_epoch() = 0 

2022-10-11 09:24:18:257357 [INFO]   hlpr_start_stream() ----> !!!!!!!!!!!!!! Vaibhav :: single_utternace :  ======== : 1

 

My application keeps on waiting for response till I close the stream.

 

As your application remains waiting until you close the stream, have you verified that the final result of the transcription is not merely taking additional time? As an example, this issue shows similar behavior involving not receiving the final transcription quickly, depending on the language. Are you experiencing the same behavior even when using a different language?