前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >微软的文本转语音服务,已经听不出是机器了

微软的文本转语音服务,已经听不出是机器了

作者头像
somenzz
发布2021-12-21 18:15:27
2K0
发布2021-12-21 18:15:27
举报
文章被收录于专栏:Python七号Python七号

今天刷到了微软在 2021 年 5 月发布的文本转语音服务(TTS),试了下,真的听不出这是机器在读,而且,可以分辨出中文的多音字,如士大夫和大(dai)夫,儿化音也可以连起来,可以自动推断出语气和情感,非常智能。感觉以后的播音员要失业了。

如果感兴趣,可以在这里[1]自己测试下。

要是微信读书里面的机器人可以这么读,那体验就更好了。

微软也给出了 Python 语言调用该服务的代码:

代码语言:javascript
复制
import azure.cognitiveservices.speech as speechsdk

# Creates an instance of a speech config with specified subscription key and service region.
# Replace with your own subscription key and service region (e.g., "westus").
speech_key, service_region = "YourSubscriptionKey", "YourServiceRegion"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)

# Creates a speech synthesizer using the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)

# Receives a text from console input.
print("Type some text that you want to speak...")
text = input()

# Synthesizes the received text to speech.
# The synthesized speech is expected to be heard on the speaker with this line executed.
result = speech_synthesizer.speak_text_async(text).get()

# Checks result.
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
    print("Speech synthesized to speaker for text [{}]".format(text))
elif result.reason == speechsdk.ResultReason.Canceled:
    cancellation_details = 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 update the subscription info?")

运行上述代码,需要你在微软的 Azure 注册一个账号,可以免费试用,具体教程[2]见文末。

最后的话

相信在不久的将来,我们完全分辨不出听到的声音是真人发出的还是机器人发出的。 参考资料

[1]这里: https://azure.microsoft.com/en-us/services/cognitive-services/text-to-speech/?ocid=AID3027325#features

[2]教程: https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=script%2Cwindowsinstall&pivots=programming-language-python

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-12-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Python七号 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 最后的话
相关产品与服务
语音合成
语音合成(Text To Speech,TTS)满足将文本转化成拟人化语音的需求,打通人机交互闭环。提供多场景、多语言的音色选择,支持 SSML 标记语言,支持自定义音量、语速等参数,让发音更专业、更符合场景需求。语音合成广泛适用于智能客服、有声阅读、新闻播报、人机交互等业务场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档