You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 15:22:54