通过google cloud API 使用 WaveNet
2021-04-10 16:27
标签:rom class 参数说明 output file content tput wav als Cloud Text-to-Speech 中使用了WaveNet,用于TTS,页面上有Demo。目前是BETA版 为了implicit调用,设置环境变量GOOGLE_APPLICATION_CREDENTIALS到你的API Key(json文件),完成后重启
python脚本:text到mp3 目前支持的6种voice type https://cloud.google.com/text-to-speech/docs/reference/rest/v1beta1/text/synthesize#audioconfig 通过google cloud API 使用 WaveNet 标签:rom class 参数说明 output file content tput wav als 原文地址:https://www.cnblogs.com/eniac1946/p/9042412.html使用方法
# [START tts_synthesize_text]
def synthesize_text(text):
"""Synthesizes speech from the input string of text."""
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
input_text = texttospeech.types.SynthesisInput(text=text)
# Note: the voice can also be specified by name.
# Names of voices can be retrieved with client.list_voices().
voice = texttospeech.types.VoiceSelectionParams(
language_code=‘en-US‘,
ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)
audio_config = texttospeech.types.AudioConfig(
audio_encoding=texttospeech.enums.AudioEncoding.MP3)
response = client.synthesize_speech(input_text, voice, audio_config)
# The response‘s audio_content is binary.
with open(‘output.mp3‘, ‘wb‘) as out:
out.write(response.audio_content)
print(‘Audio content written to file "output.mp3"‘)
# [END tts_synthesize_text]
WaveNet特性
参数说明
上一篇:rsync应用之windows和Linux之间数据传输
下一篇:C# 爬虫小程序
文章标题:通过google cloud API 使用 WaveNet
文章链接:http://soscw.com/essay/73873.html