Google文本到语音转换API音调调整 [英] Google text-to-speech API Pitch Adjustment
本文介绍了Google文本到语音转换API音调调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在此代码中将音调调整为-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这一点不太清楚。根据文档,‘螺距’可以在[-20.0,20.0]的范围内调整,但该参数可以在哪里调整。
推荐答案
audio_config = texttospeech.AudioConfig(pitch=-1.20, audio_encoding=texttospeech.AudioEncoding.LINEAR16)
这篇关于Google文本到语音转换API音调调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文