Google Cloud TTS SynthesizeLongAudio无文件生成问题求助
Google Cloud 长文本TTS服务无输出文件问题
已按照官方示例成功运行Python脚本生成本地TTS音频,但使用长音频服务时遇到异常:脚本正常执行结束且无任何报错信息,但Google Cloud Bucket中始终没有音频文件生成。
已完成以下排查操作:
- 替换了脚本中的project ID和output_gcs_uri参数
- Bucket为美国多区域,先后尝试过
"us (multiple regions in United States)"、"us"、"US"、"US-CENTRAL1"及"global"作为location参数,均未成功生成文件 - 确认服务账号拥有
Storage Object Creator和Storage Object Viewer权限,且普通TTS生成本地音频功能正常
相关代码如下:
from google.cloud import texttospeech def synthesize_long_audio(project_id, location, output_gcs_uri): """ Synthesizes long input, writing the resulting audio to `output_gcs_uri`. Example usage: synthesize_long_audio('12345', 'us-central1', 'gs://{BUCKET_NAME}/{OUTPUT_FILE_NAME}.wav') """ # TODO(developer): Uncomment and set the following variables project_id = '...' location = 'global' output_gcs_uri = 'gs://.../output.wav' client = texttospeech.TextToSpeechLongAudioSynthesizeClient() input = texttospeech.SynthesisInput( text="Test input. Replace this with any text you want to synthesize, up to 1 million bytes long!" ) audio_config = texttospeech.AudioConfig( audio_encoding=texttospeech.AudioEncoding.LINEAR16 ) voice = texttospeech.VoiceSelectionParams( language_code="en-US", name="en-US-Standard-A" ) parent = f"projects/.../locations/global" request = texttospeech.SynthesizeLongAudioRequest( parent=parent, input=input, audio_config=audio_config, voice=voice, output_gcs_uri=output_gcs_uri, ) operation = client.synthesize_long_audio(request=request) # Set a deadline for your LRO to finish. 300 seconds is reasonable, but can be adjusted depending on the length of the input. # If the operation times out, that likely means there was an error. In that case, inspect the error, and try again. result = operation.result(timeout=300) print( "\nFinished processing, check your GCS bucket to find your audio file! Printing what should be an empty result: ", result, )
内容的提问来源于stack exchange,提问作者uncommon
相关产品推荐
相关产品推荐

