• 微软的文本转语音服务Microsoft.CognitiveServices.Speech


    微软的Edge 浏览器里的大声朗读里-“晓晓” 很接近自然人,比起其它平台的强很多。

    在AZURE 可免费体验,每月限额50万字,每个语音转换不超过10分钟长度。

    C# 调用:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    using Microsoft.CognitiveServices.Speech;//nuget 添加
    using Microsoft.CognitiveServices.Speech.Audio;
    
    namespace MSTextSpeech
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                SynthesizeToSpeaker();
            }
    
            async static Task SynthesizeToSpeaker()
            {
                //Find your key and resource region under the 'Keys and Endpoint' tab in your Speech resource in Azure Portal
                //Remember to delete the brackets <> when pasting your key and region!
                var reskey = "142736。。。。。。。。。。";//<paste-your-resource-key>"
                string regon = "southeastasia";//< paste-your-region>
                var config = SpeechConfig.FromSubscription(reskey , regon);
                config.SpeechSynthesisLanguage = "zh-CN"; // e.g. "de-DE"
                                                                              // The voice setting will overwrite language setting.
                                                                              // The voice setting will not overwrite the voice element in input SSML.
                config.SpeechSynthesisVoiceName = "zh-CN-XiaoxiaoNeural";// "<your-wanted-voice>";
                using var synthesizer = new SpeechSynthesizer(config);
                await synthesizer.SpeakTextAsync("周二,这位18岁的女子在大型空中比赛中的金牌表现让她成为了全球关注的焦点,在中国引发了如此大的轰动,以至于社交媒体平台微博在兴趣的重压下崩溃了。但谷歌花了数年时间将自己打造成一名顶级运动员,同时也是一个对亚洲和西方品牌都有吸引力的高额模特。");
    
            }
    
    
    
            async void TestSaveMP3() {
    
                var reskey = "xxx2736axxxxxxx....";//<paste-your-resource-key>"
                string regon = "southeastasia";//< paste-your-region>
                var config = SpeechConfig.FromSubscription(reskey, regon);
                var path = AppDomain.CurrentDomain.BaseDirectory + "file.wav";
                using var audioConfig = AudioConfig.FromWavFileOutput(path);
                using var synthesizer = new SpeechSynthesizer(config, audioConfig);
                await synthesizer.SpeakTextAsync("A simple test to write to a file.");
    
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                TestSaveMP3();
            }
    
        }
    }
    

      

    快速入门: https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech-service/quickstarts/setup-platform?pivots=programming-language-csharp&tabs=browser%2Cdotnet%2Cwindows%2Cjre

  • 相关阅读:
    spring整合websocket通信
    Log4j学习
    Elasticsearch学习之ES节点类型以及各种节点的分工
    Elasticsearch 学习之提升性能小贴士
    Python奇技淫巧
    汉语拼音转换工具(Python 版)
    根据数据库的表结构的类型返回其对应的简写类型
    python的动态加载机制??
    计算二进制中的字符串的长度
    一个erlang游戏服务端
  • 原文地址:https://www.cnblogs.com/wgscd/p/15889178.html
Copyright © 2020-2023  润新知