Develop a Chinese speech application (C #) on the Net Platform #)

Source: Internet
Author: User
Tags sapi microsoft website

 
1. Analysis and installation of sapi.51 SDK
Sapi sdk is a free speech application development kit provided by Microsoft. It contains the speech application design interface (SAPI) and Microsoft's continuous speech recognition engine (MCSR) and Microsoft's speech synthesis (TTS) engine. The current version 5.1 supports recognition in three languages (English, Chinese and Japanese) and synthesis in two languages (English and Chinese ). SAPI also includes powerful design interfaces for low-level control and highly adaptive direct speech management, training wizard, events, syntax compilation, resources, speech recognition (SR) management, and TTS management. Its structure (1 ):

Figure (1)
The Speech Engine interacts with SAPI through the DDI layer (Device Driver Interface), and applications communicate with SAPI through the API layer. By using these APIs, you can quickly develop applications for speech recognition or speech synthesis.
Sapi5.1 SDK can be downloaded from Microsoft Website: http://www.microsoft.com/speech/download/sdk51/ requires setup for speech SDK 5.1 (68 m) and 5.1 Language Pack (81.5 m)
2. Import COM objects to. net
Sapi5.1 is based on the Windows platform and called through the COM interface. To use sapi5.1 on the. NET platform, we can use the. NET framework's powerful tool tlbimp.exe to import the COM Object of the sapi sdk to. net. Tlbimp.exe generates a controlled packaging class, which can be used by the management client. Number of reference packages for managing the actual COM object. When the packaging class is used as the collection garbage, the packaging class releases the COM object it wraps. Finished.
The following shows how to import the COM Object of SAPI:

The Directory of SAPI. dll is in C:/program files/common files/Microsoft shared/speech.

The tlbimp directory is in C:/program files/Microsoft Visual Studio 8/SDK/V2.0/bin.

Run the following command in DOS: tlbimp SAPI. dll/out: dotnetspeech. dll
After the SDK is installed, you can find sapi.dllin the C:/program files/common files/Microsoft shared/speech/directory. This defines the sapicomobject and converts the DLL. NET platform Assembly --- dotnetspeech. DLL, the conversion process will prompt a lot of warnings (warning), but this affects our development, can ignore. Finally, we can use ildasm to view the objects in dotnetspeech. dll.
3. Add reference and using dotnetspeech;
4. Programming
Test environment: vs. net2005 (C #)
Note:
For speech recognition, Chinese and English recognition depends on the language you select in "speech characteristics.
Go to "voice features" and use C:/program files/common files/Microsoft shared/speech/SAPI. CPL
You can also use Programming
Button event: // using system. diagnostics;
Processstartinfo info = new processstartinfo ();
Try
{
/* Unstated system32 files can be called directly. absolute paths must be written for addresses.

Option file name
---------------------------------------------------
Internet option: inetcpl. CPL
ODBC Data Source Management: odbccp32.cpl
Telephone and modem options: telephon. CPL
Power option: powercfg. CPL
Auxiliary Function options: Access. CPL
Region and language options: intl. CPL
Date and Time: TimeDate. CPL
Sound and audio devices: mmsys. CPL
Mouse: Main. CPL
Add or delete a program: appwiz. CPL
Add hardware: hdwwiz. CPL
Network Connection: NCPA. CPL
System: sysdm. CPL
Display: desk. CPL
User Account: nusrmgr. CPL
Game Controller: Joy. CPL
Speech: SAPI. Cpl (C:/program files/common files/Microsoft shared/speech)
Gateway services for NetWare NWC. CPL
Infrared irprops. Cpl (located in C:/Windows/driver Cache/i386/driver. cab before you install the infrared device)
-----------------------------------------------------
Fonts
------------------------------------------------------
These are common options in the control panel.

*/
Info. filename = @ "C:/program files/common files/Microsoft shared/speech/SAPI. Cpl ";
Process. Start (Info );
}
Catch (win32exception win)
{
MessageBox. Show ("error cause:" + win. message, "error", messageboxbuttons. OK, messageboxicon. Error );
}
Try
{
Speechvoicespeakflags spflags = speechvoicespeakflags. svsflagsasync;
Spvoice voice = new spvoice ();
Voice. Speak (textbox1.text, spflags );
}
Catch (exception ee)
{
MessageBox. Show ("error", "speechapp", messageboxbuttons. OK, messageboxicon. Error );
}

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.