Use Windows Narrator through .NET

烂漫一生 提交于 2020-04-13 08:02:32

问题


Is there a way to use text-to-speech capabilities of Windows Narrator in .NET applications? I want to use it or a similar service to read out loud strings from my C# application. Would that be possible?


回答1:


Ms has a speech API and now have a easily consumed managed interface.




回答2:


When using Visual Studio; in Solution Explorer.

  1. Right Click 'References' then click on 'Add Reference...'.
  2. Search for 'System.Speech' under 'Framework' then tick it.
  3. Click 'OK'

Then use code along the lines of the following:

System.Speech.Synthesis.SpeechSynthesizer mainSpeechSynthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
mainSpeechSynthesizer.Speak("Test, test. Test! TEST.");

Here's a nice breakdown of how to use System.Speech.Synthesis with examples:

Initialize and Manage the Speech Synthesizer



来源:https://stackoverflow.com/questions/9638965/use-windows-narrator-through-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!