【问题标题】:Google text-to-speech API Pitch AdjustmentGoogle 文字转语音 API 音高调整
【发布时间】:2021-06-02 05:20:09
【问题描述】:

如何在这段代码中将音高调整为 -1.20:

from google.cloud import texttospeech

def text_to_wav(voice_name, text):
    language_code = "-".join(voice_name.split("-")[:2])
    text_input = texttospeech.SynthesisInput(text=text)
    voice_params = texttospeech.VoiceSelectionParams(
        language_code=language_code, name=voice_name)

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

    client = texttospeech.TextToSpeechClient()
    response = client.synthesize_speech(
        input=text_input, voice=voice_params, audio_config=audio_config)

    filename = f"{language_code}.wav"
    with open(filename, "wb") as out:
        out.write(response.audio_content)
        print(f'Audio content written to "{filename}"')

Google Text-to-Speech documentation 对此并不十分清楚。根据文档,'pitch' 可以在 [-20.0, 20.0] 范围内调整,但是这个参数可以在哪里调整。

【问题讨论】:

标签: python-3.x text-to-speech google-text-to-speech


【解决方案1】:
audio_config = texttospeech.AudioConfig(pitch=-1.20, audio_encoding=texttospeech.AudioEncoding.LINEAR16)

【讨论】:

  • 您好,欢迎来到 SO!虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。请阅读tourHow do I write a good answer?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-29
  • 1970-01-01
  • 1970-01-01
  • 2019-02-18
  • 2015-03-11
  • 1970-01-01
  • 2012-04-11
相关资源
最近更新 更多