C # getting started with developing a speech program

Source: Internet
Author: User
Tags sapi


To use C # To develop a Speech program, you must first have the Speech API (SPAI) on your computer ).

By reading this section, you can see whether your computer has installed SPAI:

The Speech API has been an integral component of all Microsoft Windows

Versions since Windows 98. Microsoft Windows XP and Windows Server 2003

Include SAPI version 5.1. Windows Vista and Windows Server 2008 include SAPI

Version 5.3, while Windows 7 des SAPI version 5.4. Code written for SAPI
5.3 (Vista)

Will run on SAPI 5.4 (Windows 7) without recompiling.

Both versions 5.1 and later support Chinese, Japanese, and English languages.

Let's take a look at the example and explain it with a small example:

Create a project-windows Forms application, with the name SpeechDemo

 


Since my computer is win7, you can add reference directly:

 

Form code:


[Csharp]
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Text;
Using System. Windows. Forms;
Using SpeechLib;
 
Namespace SpeechDemo
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
 
Private void btnSpeech_Click (object sender, EventArgs e)
{
SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags. SVSFlagsAsync;
SpVoice Voice = new SpVoice ();
Voice. Speak (textBox1.Text, SpFlags );

}
}
}
The code is very simple. As long as you enter Chinese or English in the text box, you can read it normally.

 

 


For functions under the SpVoice interface, see: http://msdn.microsoft.com/en-us/library/ee413476 (v = vs.85)

 


Help connection: http://www.microsoft.com/en-us/Tellme/developers/default.aspx? Tab = desktop


We can see that there are many interfaces in the text-to-speech engine interface (api-level), and many things make us confused. At this time, we should analyze them carefully, find what we need, understand the functions and interfaces we want to call, and do not be intimidated by the things we are not familiar with. Learn the learning method and the learning method by the way, I think this is important.
Author: yjjm1990

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.