okass 在版块 人工智能AI 中发起了话题 Ubuntu 创建微软Azure TTS服务 2年, 10个月前
运行环境:Ubuntu+Python
1. 到微软官方创建一个Azure 免费账户,需要信用卡认证
2、Ubuntu端配置:
# sudo apt-get update
# sudo apt-get install python libssl1.0.0 libasound2
# pip install azure-cognitiveservices-speech3. 语音合成python源码
## 输入文件text.txt
## 输出文件file.wavfrom azure.cognitiveservices.speech import AudioDataStream, SpeechConfig, SpeechSynthesizer, SpeechSynthesisOutputFormat
from azure.cognitiveservices.speech.audio import AudioOutputConfig
import azure.cognitiveservices.speech as speechsdkspeech_key, service_region = “xxxxxxxxxxxxxxxxxxxxxxxxx”, “xxxxxx”
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)speech_config.speech_synthesis_language = “zh-CN”
speech_config.speech_synthesis_voice_name =”zh-CN-XiaoyouNeural”audio_config = AudioOutputConfig(filename=”file.wav”)
synthesizer = SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)with open(‘text.txt’, ‘r’,encoding=’utf-8′,errors=’ignore’) as f:
text = f.read()result = synthesizer.speak_text_async(text).get()
stream = AudioDataStream(result)
stream.save_to_wav_file(“file.wav”)4. 运行方式
# python test.py
# ./test.py
最后在线: 活跃于 6个月, 2周前
评论: 7
获赞: 0
文章: 0
粉丝: 68
关注: 68
好友: 8
User Rating: ( vote)