Skip to main content

Posts

Showing posts with the label polling

async google long speech recognition with polling

Async google long speech recognition with polling import io import os import time # Imports the Google Cloud client library from google.cloud import speech from google.cloud.speech import enums from google.cloud.speech import types def transcribe_gcs(gcs_uri): """Asynchronously transcribes the audio file specified by the gcs_uri.""" from google.cloud import speech from google.cloud.speech import enums from google.cloud.speech import types client = speech.SpeechClient() audio = types.RecognitionAudio( uri =gcs_uri) config = types.RecognitionConfig( # encoding=enums.RecognitionConfig.AudioEncoding.FLAC, # sample_rate_hertz=16000, language_code = 'en-US' ) operation = client.long_running_recognize(config, audio) print ( 'Waiting for operation to complete...' ) retry_count = 1000000 while retry_count and not operation.done(): retry_count -= 1 print ...