Speech V1 Streaming VoiceActivityTimeout not respected

cc22
New Member

Hi, I'm following the tutorial here: https://cloud.google.com/speech-to-text/docs/samples/speech-transcribe-streaming-mic?hl=en 

This is working, but I want to add a voice_activity_timeout to my StreamingRecognitionConfig as noted here: https://cloud.google.com/python/docs/reference/speech/latest/google.cloud.speech_v1.types.StreamingR...

I'm trying to add a delay with speech_end_timeout, but it's not respected. It just closes the stream immediately after detecting anything that is marked with is_final, no matter what I set the speech_end_timeout to be. Without voice_activity_timeout, it just does not close the stream, but everything else is the same.

 

    config = speech.RecognitionConfig(
        encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
        sample_rate_hertz=RATE,
        language_code=language_code,
    )

    timeout = Duration(seconds=5)

    streaming_config = speech.StreamingRecognitionConfig(
        config=config, interim_results=True,
        enable_voice_activity_events=True,
        voice_activity_timeout=speech.StreamingRecognitionConfig.VoiceActivityTimeout(
            speech_end_timeout=timeout
        )
    )

 

Thanks in advance. 

0 1 68
1 REPLY 1

It's important to note that the voice_activity_timeout parameter is not currently supported in the Google Cloud Speech-to-Text Python client library.

The voice_activity_timeout parameter is indeed present in the API documentation, but it may not be fully implemented or available in the Python client library yet. This could explain why setting the speech_end_timeout doesn't have any effect on your streaming recognition session.

As an alternative, you may need to implement your own logic to handle the closing of the streaming recognition session based on the presence of speech or silence. One approach could be to monitor the voice activity events (is_final results and voice_activity_info) and implement a timeout mechanism in your code based on your requirements.