微软Azure
https://portal.azure.com/ 注册后绑定visa卡

创建微软语音服务
创建资源

选择AI应用和代理 -》 语音

输入语音服务必填项

然后点击创建

创建完成后如下

点击转到资源
语音服务

点击转到SpeechStudio

语音库

没有有声内容创作,切换到旧外观

出现有声内容创作

SDK
开发文档:
https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-text-to-speech?tabs=macos&pivots=programming-language-csharp
Github示例代码:
https://github.com/Azure-Samples/cognitive-services-speech-sdk
Python代码调用
VSCode下载Azure AI Speech Toolkit

安装azure包
pip install azure-cognitiveservices-speechimport os
import azure.cognitiveservices.speech as speechsdk
# This example requires environment variables named "SPEECH_KEY" and "ENDPOINT"
# Replace with your own subscription key and endpoint, the endpoint is like : "https://YourServiceRegion.api.cognitive.microsoft.com"
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY'), endpoint=os.environ.get('ENDPOINT'))
audio_config = speechsdk.audio.AudioOutputConfig(use_default_speaker=True)
# The neural multilingual voice can speak different languages based on the input text.
speech_config.speech_synthesis_voice_name='zh-CN-XiaoxiaoNeural'
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
# Get text from the console and synthesize to the default speaker.
print("Enter some text that you want to speak >")
text = input()
speech_synthesis_result = speech_synthesizer.speak_text_async(text).get()
if speech_synthesis_result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
print("Speech synthesized for text [{}]".format(text))
elif speech_synthesis_result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = speech_synthesis_result.cancellation_details
print("Speech synthesis canceled: {}".format(cancellation_details.reason))
if cancellation_details.reason == speechsdk.CancellationReason.Error:
if cancellation_details.error_details:
print("Error details: {}".format(cancellation_details.error_details))
print("Did you set the speech resource key and endpoint values?") 如果这篇文章对你有用,可以关注本人微信公众号获取更多ヽ(^ω^)ノ ~

















