C # Read text play corresponding speech "go"

Source: Internet
Author: User

The first scenario:

Use Microsoft Text to Speech engine (TTS) to read text

(1) Add a project reference to the Microsoft Speech Object Library

(2) introducing a using Speechlib name control

(3) Reading text

Speechvoicespeakflags flag = Speechvoicespeakflags.svsflagsasync; SpVoice voice = new SpVoice ();

Default to the corresponding entry in the language selection, text-to-speech, Recording tab, Control Panel, sound, and so on, such as Microsoft Lily or Microsoft Sam

The "Pre-listening voice" test can be used here to ensure that the operating system itself correctly configures the voice packet, especially the B/s structure is often ignored

Otherwise, an exception is thrown: "There is no registered class (Exception from hresult:0x80040154 (Regdb_e_classnotreg))"

Voice. Voice = Voice. Getvoices (String. Empty, String. Empty).         Item (0); Voice. Speak (TextBox1.Text, flag);

(4) Language Pack selection (pro-Test)

Only Microsoft Sam is installed by default in WindowsXP, and only English can be read aloud, not Chinese, and skipped directly. (Not recommended)

Looking for a microsoft_tts_51_chs.msi installed later a Microsoft Simplified Chinese voice pack, but only read Chinese, can not read English words, the word is broken into letters read out (all Chinese can)

Microsoft Lili is installed by default in Windows VISTA/7, can be mixed in English, but sounds better (recommended), but the XP system cannot be installed, and Microsoft Anna can only read English (not recommended).

Scansoft-meiling-chinesemandarinvoice can be installed under XP, but polyphone recognition is not good, the advantage is relatively small, about 40M.

NeoSpeech Lily, the sound works better than Microsoft Lili. Recommended use, but relatively big 500M or so.

The second scenario:

System.Speech.Synthesis (voice synthesizer)

Let's take a look at an example of how to use speech synthesis from a managed application. As a typical example of a UI output, I'll start with an application that only says "Hello, World," as shown in Figure 5 .

<em>using System;using System.Speech.Synthesis; namespace TTS_Console_Sample_1{    class Program    {        static void Main(string[] args)        {            SpeechSynthesizer synth = new SpeechSynthesizer();            synth.SpeakText("Hello, world!");        }    }}</em>

The example is an obvious console application that was recently created with Visual c#®, which adds three lines of code. The first line added only introduces the System.Speech.Synthesis namespace. The second line declares and instantiates an instance of SpeechSynthesizer, which accurately represents the meaning of its name: the speech synthesizer. The third line that is added is a call to SpeakText. This is all that is required to call the synthesizer.

By default, the SpeechSynthesizer class uses the synthesizer that is recommended by default in the Speech Control Panel. However, it can use any synthesizer compatible with the SAPI DDI.

C # Read text play corresponding speech "go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.