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

Google Text to Speech: Encountering high latency

Hi,

I am using Google Text to Speech client library according to the following code:

 
gcp_creds = service_account.Credentials.from_service_account_info()
client = texttospeech.TextToSpeechClient(credentials=gcp_creds)
synthesis_input = texttospeech.SynthesisInput(text=text)
 
if <insert language detecting logic>:
language = "hi-IN"
else:
language = "en-IN"

voice = texttospeech.VoiceSelectionParams(
language_code=language, name=language + "-Standard-D"
)
 
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.LINEAR16,
sample_rate_hertz=RATE,
speaking_rate=0.9,
pitch=0,
effects_profile_id=["telephony-class-application"],
)

res = client.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
 
I'm experiencing very high latency, from 500 ms to 22000 ms. I have tried reducing this using different configurations but was unsuccessful. 
 
How can I reduce latency to below 500 ms?
0 1 833
1 REPLY 1

You may reach out to https://cloud.google.com/support for better troubleshooting steps so that your project may be properly inspected regarding this latency issues.