Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum size of Google Cloud Text-to-Speech requests

When I submit synthesis requests for text that is too long, I get the following error:

google.api_core.exceptions.ResourceExhausted: 429 Received message larger than max (X vs. 4194304)

Where "X" is the size in bytes of the returned request. Why are requests limited to 4MB? I know that requests are limited to 5000 characters, but my requests are ~1500 characters, nowhere near the limit. Is it possible to receive messages larger than 4MB? Or is the 5000 character limit not the real bottleneck to Google text-to-speech?

If it changes anything, I'm using different en-us Wavenet voices with LINEAR16 encoding.

like image 763
Vinay Raghavan Avatar asked Feb 10 '20 21:02

Vinay Raghavan


1 Answers

Here is a programmatic fix (Python) that worked for me (as proposed in this GitHub post: https://github.com/googleapis/python-texttospeech/issues/5#issuecomment-709562585)

from google.cloud import texttospeech_v1
from google.cloud.texttospeech_v1.services.text_to_speech.transports.grpc import (
    TextToSpeechGrpcTransport,
)

channel = TextToSpeechGrpcTransport.create_channel(
    options=[("grpc.max_receive_message_length", 24 * 1024 * 1024)]
)
transport = TextToSpeechGrpcTransport(channel=channel)
client = texttospeech_v1.TextToSpeechClient(transport=transport)
like image 137
majom Avatar answered Oct 09 '22 07:10

majom