【问题标题】:Google Text to Speech – words not read after break谷歌文本到语音 - 休息后不读的词
【发布时间】:2021-11-05 08:15:53
【问题描述】:

我正在尝试让 Google TTS 朗读一小段单词并在每个单词之间暂停。我发送到 Google Cloud 的 SSML 示例:

<speak>chaume<break time="3s"/> cuivré, relatif au cuivre</speak>

第一个单词被读出,然后声音停顿三秒钟,但后面的所有内容都被放下了。我已经成功让 TTS 使用相同的代码读取包含中断的较长句子,例如这个:

<speak>Se pure vagolavano allora per una Parma stupenda, prima dello <break time="3s"/>scempio della Bassa dei Magnani orrendamente ricostruita.</speak>

两个样本之间没有任何差异,第一个样本出了什么问题?

我的合成功能稍微定制的版本如下:

def synthesize_text(ssml_text,file_name,tts_lang,tts_voice_name):
    """Synthesizes speech from the input string of text."""

    client = texttospeech.TextToSpeechClient(credentials=credentials)

    input_text = texttospeech.SynthesisInput(ssml=ssml_text)

    # Note: the voice can also be specified by name.
    # Names of voices can be retrieved with client.list_voices().
    voice = texttospeech.VoiceSelectionParams(
        language_code=tts_lang,
        name=tts_voice_name,
        ssml_gender=texttospeech.SsmlVoiceGender.FEMALE,
    )

    audio_config = texttospeech.AudioConfig(
        audio_encoding=texttospeech.AudioEncoding.MP3
    )

    response = client.synthesize_speech(
        request={"input": input_text, "voice": voice, "audio_config": audio_config}
    )

    # The response's audio_content is binary.
    with open(f"{home}/Documents/{file_name}.mp3", "wb") as out:
        out.write(response.audio_content)

【问题讨论】:

    标签: google-cloud-platform text-to-speech


    【解决方案1】:

    事实证明,删除以下几行就足够了:

    name=tts_voice_name,
    ssml_gender=texttospeech.SsmlVoiceGender.FEMALE
    

    voice_namefr-FR-Standard-A,是 WaveNet 的声音。而语言代码是fr-CA。我很确定这种差异导致了奇怪的行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      • 2011-05-01
      相关资源
      最近更新 更多