0

I am trying to implement the Speech-to-Text API in this tutorial using Cloud Functions (python)

Speech-to-Text long running

The one implemented here is an asynchronous, long running function. My aim is to have the Cloud Function download an audio from a site, write it to S3, then calls the Speech-to-Text APIs client function on that S3 location of the audio to return a transcibed text. Here is the shortened code from the tutorial:

from google.cloud import speech_v1 as speech

client = speech.SpeechClient()
# storage_uri = 'gs://cloud-samples-data/speech/brooklyn_bridge.raw'
# some configuration
audio = {"uri": storage_uri}
operation = client.long_running_recognize(config, audio)

However, in cases where the audio is too long, it won't fit even the maximum timeout in the Cloud Function and I get timeout in logs. The client.long_running_recognize was probably finished by Speech-to-Text API but the Cloud Function can't wait for it. What should I do in this case? Is using the asyncio library in Python a good solution?

oikonomiyaki
  • 7,691
  • 15
  • 62
  • 101

1 Answers1

2

Cloud Functions currently have a maximum timeout of up to 9 minutes.

You could use other GCP services that can perform longer operations. For example, App Engine Flexible has a response time limit of 60 minutes or App Engine Standard with basic scaling which has a response time limit of 24 hours

Jose V
  • 1,356
  • 1
  • 4
  • 12