码迷,mamicode.com
首页 > 其他好文 > 详细

简单C#文字转语音

时间:2014-09-13 17:03:25      阅读:145      评论:0      收藏:0      [点我收藏+]

标签: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#文字转语音

标签:blog   io   ar   div   sp   代码   log   on   c   

原文地址:http://www.cnblogs.com/MichaelCrane/p/3969884.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!