C # Speech Recognition usage examples

Source: Internet
Author: User
Tags bit set

The examples in this article describe the use of C # speech recognition. Share to everyone for your reference. The specific analysis is as follows:

C # can take advantage of the Microsoft operating system's automatic speech recognition function to read information. The steps are as follows:

1. Add "" References in the project

2. Introduce namespaces:


The code is as follows:

Using Speechlib;

3. Read the code:


The code is as follows:

Speechvoicespeakflags flag = Speechvoicespeakflags.svsflagsasync;

SpVoice voice = new SpVoice ();

Voice. Voice = Voice. Getvoices (String. Empty, String. Empty). Item (0);

Voice. Speak ("You are a big beauty, I try a handsome pot, haha", flag);

which

1. Speechvoicespeakflags is an enumeration.

SpVoice Logo:

Svsfdefault = 0

Svsflagsasync = 1

Svsfpurgebeforespeak = 2

Svsfisfilename = 4

Svsfisxml = 8

Svsfisnotxml = 16

Svsfpersistxml = 32

Regularization flag:

Svsfnlpspeakpunc = 64

Mask:

Svsfnlpmask = 64

Svsfvoicemask = 127

Svsfunusedflags =-128

End enumeration molecule

Svsfdefault

Specifies the default settings that should be used. The default values are:

Fixed text string synchronization (overwrite with Svsflagsasync),

Do not clear pending talk requests (overwrite with Svsfpurgebeforespeak),

In order to parse the text of the XML, if the first character is a left angle bracket (overwriting with svsfisxml or svsfisnotxml),

Do not adhere to global XML state changes in the talk call (overwrite Svsfpersistxml),

Do not extend the punctuation word literal (overwrite with svsfnlpspeakpunc).

Svsflagsasync

The specified talk call should be asynchronous. That is, it returns immediately after the queued talk request.

Svsfpurgebeforespeak

Clear all pending speech requests, before speaking of calls.

Svsfisfilename

The way the string is passed is a file name, not a literal. As a result, there is no spoken string itself but the path to the file, which is handled orally.

Svsfisxml

The text entered will be parsed into an XML tag.

Svsfisnotxml

The input text will not be parsed by the XML tag.

Svsfpersistxml

Changes in the global state of the XML tag will persist to the spoken call.

Svsfnlpspeakpunc

, punctuation should be extended to words (for example: "What is this.") "Will become" this is the issue ").

Svsfnlpmask

SAPI (instead of the text-to-speech engine) handles flags in this mask.

Svsfvoicemask

This mask has each flag bit set.

Svsfunusedflags

This mask has every unused bit set.

2. SpVoice

The SpVoice class is a core class that supports speech synthesis (TTS). The TTS engine is invoked through the SpVoice object to enable read aloud functionality.

The SpVoice class has the following main properties:

Voice: Represents the type of pronunciation, which is equivalent to those who speak aloud, including Microsoft Mary,microsoft mike,microsoft Sam and Microsoft Simplified Chinese four kinds. The first three kinds can only read English, the last one can read Chinese, but also can read English, but for English words can only be included in each letter read out. We will find a way to solve this problem in the following procedure.

Rate: The speed of speech reading, the value range is 10 to +10. The higher the value, the faster the speed.

Volume: volume, with values ranging from 0 to 100. The larger the number, the greater the volume.

SpVoice has the following main methods:

Speak: Completes the conversion of text information to speech and reads it according to the specified parameters, which has text and flags two parameters, specifying the text to read aloud and how to read aloud (synchronous or asynchronous, etc.).

Pause: Pauses all the read-aloud processes that use the object. The method has no parameters.

Resume: Resumes the paused read-aloud process corresponding to the object. The method has no parameters.

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration, Running GuestArticles are original, reproduced please link to the form of the address of this article
C # Speech Recognition usage examples

This address: http://www.paobuke.com/develop/c-develop/pbk23198.html






Related content C # using MCI to create a video or sound player source code download C # Implementation of SQL backup and restore functionality example C # Implementation of Baidu ping push function C # method of exporting data to Excel using OLE DB
C # calling DOS Windows to get related information C # converts a picture and a byte stream to each other and displays it on the page C # uses the Itextsharp encapsulated PDF file Operation class Instance C # WinForm cross-thread access to the control instance

C # Speech Recognition usage examples

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.