zoukankan      html  css  js  c++  java
  • 合成语音 TTS

    弄了一天的合成语音 感觉好难受,明明这么简单的事情非弄得要这么复杂....

    引入命名空间

    或者

    导入命名空间

    代码:

    using System;
    using System.Collections.Generic;
    using System.Speech.Synthesis;
    namespace TheSpeeCh
    {
        class Program
        {
            private static SpeechSynthesizer speech;
    
            static List<VoiceInfo> voiceList = new List<VoiceInfo>();
    
            /// <summary>
            /// 音量
            /// </summary>
            private static int Volumevalue = 100;
            static void Main(string[] args)
            {
                speech = new SpeechSynthesizer();
                getVoiceInfos();
                Speak($@"朕统六国,天下归一,筑长城以镇九州龙脉,卫我大秦、护我社稷。朕以始皇之名在此立誓!朕在,当守土开疆,扫平四夷,定我大秦万世之基!朕亡,亦将身化龙魂,佑我华夏永世不衰!此誓,日月为证,天地共鉴,仙魔鬼神共听之!");
                Console.Read();
            }
            public static List<VoiceInfo> getVoiceInfos()
            {
               
    
                using (SpeechSynthesizer synth = new SpeechSynthesizer())
                {
                    foreach (InstalledVoice voice in synth.GetInstalledVoices())
                    {
                        voiceList.Add(voice.VoiceInfo);
                    }
                }
                return voiceList;
            }
            public static void Speak(string Content) {
               
                speech.Rate = 1;//语速
                string Name;
                if (!voiceList[0].AdditionalInfo.TryGetValue("Name",out Name))
                    return;
                speech.SelectVoice(Name);//设置播音员
                speech.Volume = Volumevalue;//音量
                speech.SpeakAsync(Content);//语音阅读方法
            }
        }
    }

    如果包这个错误  表示没有安装语音包

    语音包下载地址

    http://www.443w.com/tts/?post=2

    真是一个好网站

    同时也支持导出语音到文件流

    表示可以做出C/S形式

    微软 API

    https://msdn.microsoft.com/en-us/library/ms723627%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

  • 相关阅读:
    网络状态码含义——(比如204,304, 404, 504,502)
    Vue两个简易代替vuex的方法(eventBus,observable)
    单页面首屏加载慢解决方案
    前端监控和前端埋点
    ES5 和 ES6的继承
    mysql 隔离级别
    mysql 事务
    Seata
    Sentinel Dashboard 部署
    java 垃圾回器
  • 原文地址:https://www.cnblogs.com/AnAng/p/8832408.html
Copyright © 2011-2022 走看看