簡單C#文字轉語音

來源:互聯網
上載者:User

標籤:blog   io   ar   div   sp   代碼   log   on   c   

跟著微軟走妥妥的,C#文字轉語音有很多參數我就不說了,畢竟我也是初學者。跟大家分享最簡單的方法,要好的效果得自己琢磨嘍;

先添加引用System.Speech程式集;

using System;using System.Speech.Synthesis;namespace ConsoleApplication2{    class Program    {        static void Main(string[] args)        {                                     SpeechSynthesizer hello = new SpeechSynthesizer();            string str = "請輸入您的名字";            hello.Speak(str);  //Speak(string),Speak加上字串類型的參數            Console.ReadKey();         }         

我個人覺得有些時候就是要直接講重點,要的就是這種簡單粗暴,呵呵

雖是簡單的代碼,多段疊加就不得了啊,個人覺得編程就是要用最少的代碼幹最多的事。

簡單的代碼加上不同的想法就有不同的效果

using System;using System.Speech.Synthesis;namespace ConsoleApplication2{    class Program    {        static void Main(string[] args)        {                         /*下面這個程式不支援英文,我剛接觸,英文的我還不懂,呵呵*/            SpeechSynthesizer hello = new SpeechSynthesizer();            string str = "請輸入您的名字";            Console.WriteLine(str);            hello.Speak(str);            string input = Console.ReadLine();            Console.WriteLine ("你好,"+input);            hello.Speak("你好,"+input);            str = "我是您的助手,很高興認識你";            Console.WriteLine(str);            hello.Speak(str);              Console.ReadKey();         }         }}

 這是我第一次寫博文,寫得不好的地方請多多包涵,若有錯的地方歡迎指正,謝謝!

 

簡單C#文字轉語音

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.