如何在此代码中将音调调整为-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}"')
The Google 文本转语音文档 https://cloud.google.com/text-to-speech/docs/reference/rest/v1/text/synthesize#audioconfig对此还不太清楚。根据文档,“pitch”可以在[-20.0, 20.0]范围内调整,但是这个参数可以在哪里调整。
audio_config = texttospeech.AudioConfig(pitch=-1.20, audio_encoding=texttospeech.AudioEncoding.LINEAR16)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)