当前位置: 首页>>代码示例>>C#>>正文


C# SpeechSynthesizer.SetOutputToDefaultAudioDevice方法代码示例

本文整理汇总了C#中SpeechSynthesizer.SetOutputToDefaultAudioDevice方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechSynthesizer.SetOutputToDefaultAudioDevice方法的具体用法?C# SpeechSynthesizer.SetOutputToDefaultAudioDevice怎么用?C# SpeechSynthesizer.SetOutputToDefaultAudioDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpeechSynthesizer的用法示例。


在下文中一共展示了SpeechSynthesizer.SetOutputToDefaultAudioDevice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            string sURL;
            sURL = "http://api.nytimes.com/svc/topstories/v1/yourAPIKey";
            WebRequest wrGETURL;
            wrGETURL = WebRequest.Create(sURL);
            wrGETURL.Proxy = WebProxy.GetDefaultProxy();
            Stream objStream;
            objStream = wrGETURL.GetResponse().GetResponseStream();
            StreamReader objReader = new StreamReader(objStream);
            string line = "";
            line = objReader.ReadLine();
            line = line.Replace("\"abstract\"","\"abstra\"");
            dynamic stories = JsonConvert.DeserializeObject<Rootobject>(line);
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {

                // Configure the audio output.
                synth.SetOutputToDefaultAudioDevice();
                for (int i = 0; i < stories.num_results; i++)
                {
                    // Speak a string synchronously.
                    string number = i.ToString();
                    synth.Speak(number+ "\n" + stories.results[i].title);
                    synth.Speak(stories.results[i].abstra);
                }
            }
        }
开发者ID:ycen,项目名称:TimeSpeak,代码行数:28,代码来源:Program.cs

示例2: MainForm

        public MainForm()
        {
            InitializeComponent();
            message = new Dictionary<char, string>() {
                {'+',"increase screen opacity"},
                {'-',"decrease screen opacity"},
                {'1',"change color"},
                {'2',"change color"},
                {'3',"red light on"},
                {'4',"green light on"},
                {'5',"switch to night time"},
                {'6',"switch to day time"},
                {'7',"make snows"},
                {'8',"show rainbow"},
                {'9',"show bunny"},
                {'0',"make the bunny jump"}
            };

            synth = new SpeechSynthesizer();
            synth.SetOutputToDefaultAudioDevice();

            cars = new List<Car>();
            bunny = new Bunny(new Point(20, 20));
            rainbow = new Rainbow(new Point(0, 0));
            snow = new Snow(new Point(0, 0));
            traffic = new Traffic();

            sun = new Sun(new Point(Size.Width - 250, 10));
            moon = new Moon(new Point(Size.Width - 250, 10));

            carSound = new SoundPlayer(@"carSounds.wav");
            windSound = new SoundPlayer(@"Wind.wav");
            brake = new SoundPlayer(@"car-brake.wav");
        }
开发者ID:ghuang2013,项目名称:Children-s-Animation,代码行数:34,代码来源:Form1.cs

示例3: Form1_Load

 private void Form1_Load(object sender, EventArgs e)
 {
     rastreamento = new Rastreamento();
     speech = new SpeechSynthesizer();
     speech.SetOutputToDefaultAudioDevice();
     datas = new List<RastreamentoCorreios.Data>();
 }
开发者ID:jeanls,项目名称:CorreiosLib,代码行数:7,代码来源:Form1.cs

示例4: initVoice

 /// <summary>
 /// Initiate the SpeechSynthesizer.
 /// </summary>
 /// <returns></returns>
 public static SpeechSynthesizer initVoice()
 {
     synth = new SpeechSynthesizer();
     synth.SetOutputToDefaultAudioDevice();
     synth.SelectVoice(voiceName);
     return synth;
 }
开发者ID:huclepi,项目名称:PCH-Recognition,代码行数:11,代码来源:Voice.cs

示例5: ConfigureVoice

 public static bool ConfigureVoice(SpeechSynthesizer synth, string name, int speed, int volume, bool defaultOutput, int customOutput)
 {
     try
     {
         synth.SetOutputToDefaultAudioDevice();
         if (!defaultOutput)
         {
             HackCustomDevice(synth, customOutput);
             // do stuff.
         }
     }
     catch
     {
     }
     if (string.IsNullOrEmpty(name))
         name = initialName;
     try
     {
         if (!string.IsNullOrEmpty(name))
             synth.SelectVoice(name);
     }
     catch
     {
         return false;
     }
     synth.Rate = speed;
     synth.Volume = volume;
     return true;
 }
开发者ID:Tilps,项目名称:Stash,代码行数:29,代码来源:ChatSettingsForm.cs

示例6: SpeechConversation

        public SpeechConversation(SpeechSynthesizer speechSynthesizer = null, SpeechRecognitionEngine speechRecognition = null)
        {
            SessionStorage = new SessionStorage();
            if(speechSynthesizer==null)
            {
                speechSynthesizer = new SpeechSynthesizer();
                speechSynthesizer.SetOutputToDefaultAudioDevice();
            }
            _speechSynthesizer = speechSynthesizer;
            if(speechRecognition==null)
            {
                speechRecognition = new SpeechRecognitionEngine(
                    new System.Globalization.CultureInfo("en-US")
                );
                // Create a default dictation grammar.
                DictationGrammar defaultDictationGrammar = new DictationGrammar();
                defaultDictationGrammar.Name = "default dictation";
                defaultDictationGrammar.Enabled = true;
                speechRecognition.LoadGrammar(defaultDictationGrammar);
                // Create the spelling dictation grammar.
                DictationGrammar spellingDictationGrammar = new DictationGrammar("grammar:dictation#spelling");
                spellingDictationGrammar.Name = "spelling dictation";
                spellingDictationGrammar.Enabled = true;
                speechRecognition.LoadGrammar(spellingDictationGrammar);

                // Configure input to the speech recognizer.
                speechRecognition.SetInputToDefaultAudioDevice();
            }
            _speechRecognition = speechRecognition;
        }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:30,代码来源:SpeechConversation.cs

示例7: AerTalk

 public AerTalk()
 {
     rand = new Random();
     LastSpelledWord = "";
     _synth = new SpeechSynthesizer();
     _synth.SetOutputToDefaultAudioDevice();
 }
开发者ID:4-Dtech,项目名称:AerSpeech,代码行数:7,代码来源:AerTalk.cs

示例8: Speaker

        public Speaker(Language lang = Language.English)
        {
            this.lang = lang;
            AsyncMode = false;  // Default to synchron speech
            UseSSML = false;	// Default to non-SSML speech

            try
            {
                // Create synthesizer
                ss = new SpeechSynthesizer();
                ss.SetOutputToDefaultAudioDevice();

                // Select language
                if (!UseSSML)
                {
                    switch (lang)
                    {
                        case Language.English: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)"); break;
                        case Language.Finish: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (fi-FI, Heidi)"); break;
                        case Language.Norwegian: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (nb-NO, Hulda)"); break;
                        case Language.Russian: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (ru-RU, Elena)"); break;
                        case Language.Swedish: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (sv-SE, Hedvig)"); break;
                        default: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)"); break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occured: '{0}'", e);
            }
        }
开发者ID:TommyAGK,项目名称:Flex,代码行数:31,代码来源:Speaker.cs

示例9: ConsoleSpeechChatSession

        public ConsoleSpeechChatSession()
        {
            SessionStorage = new SessionStorage();

            SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
            speechSynthesizer.SetOutputToDefaultAudioDevice();
            _speechSynthesizer = speechSynthesizer;
        }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:8,代码来源:ConsoleSpeechChatSession.cs

示例10: Speech

 public Speech()
 {
     sr = new SpeechRecognitionEngine();
     ss = new SpeechSynthesizer();
     sr.SetInputToDefaultAudioDevice();
     ss.SelectVoice("Microsoft Anna");
     ss.SetOutputToDefaultAudioDevice();
 }
开发者ID:nbotti,项目名称:Assistant,代码行数:8,代码来源:Speech.cs

示例11: CoachSpeech

        public CoachSpeech()
        {
            synth = new SpeechSynthesizer();
            synth.SetOutputToDefaultAudioDevice();

            synth.SpeakStarted += SpeakStarted;
            synth.SpeakCompleted += SpeakCompleted;
            synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-US, Helen)");
        }
开发者ID:jrafidi,项目名称:kinect-fencing-coach,代码行数:9,代码来源:CoachSpeech.cs

示例12: Tts

        /*
         * Text to Speech
         */
        public Tts()
        {
            //create speech synthesizer
            tts = new SpeechSynthesizer();
            tts.SetOutputToDefaultAudioDevice();

            //set voice
            tts.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT"));
        }
开发者ID:Felgueiras,项目名称:IM-Calculator,代码行数:12,代码来源:Tts.cs

示例13: Play

 public void Play()
 {
     using (SpeechSynthesizer synth = new SpeechSynthesizer())
     {
         synth.SelectVoiceByHints(VoiceGender, VoiceAge, VoicePosition, new CultureInfo(CultureInfo));
         synth.SetOutputToDefaultAudioDevice();
         synth.Volume = Volume;
         synth.Rate = Rate;
         synth.Speak(Text);
     }
 }
开发者ID:neowutran,项目名称:ShinraMeter,代码行数:11,代码来源:TextToSpeech.cs

示例14: AddEndpoint

 public void AddEndpoint(string ID, Stream outstream)
 {
     SpeechSynthesizer voice = new SpeechSynthesizer();
     if (outstream == null) voice.SetOutputToDefaultAudioDevice();
     else voice.SetOutputToAudioStream(outstream, new System.Speech.AudioFormat.SpeechAudioFormatInfo(
         16000, System.Speech.AudioFormat.AudioBitsPerSample.Sixteen, System.Speech.AudioFormat.AudioChannel.Mono));
     //if (chkIVONA.Checked) voice.SelectVoice("IVONA 2 Amy");
     //else voice.SelectVoice("Microsoft Anna")
     voices.Add(ID, voice);
     outStreams.Add(ID, outstream);
 }
开发者ID:kingtut666,项目名称:holly,代码行数:11,代码来源:SpeechOut.cs

示例15: frmThankYou_Load

        private void frmThankYou_Load(object sender, EventArgs e)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();

            // Configure the audio output.
            synth.SetOutputToDefaultAudioDevice();

            // Speak a string.
            synth.Speak(lblQuestion.Text);
        }
开发者ID:erato,项目名称:HCVQuestionnaire,代码行数:11,代码来源:frmThankYou.cs


注:本文中的SpeechSynthesizer.SetOutputToDefaultAudioDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。