- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
Form1.cs
资源名称:speech.rar [点击查看]
上传用户:cookies0
上传日期:2022-07-28
资源大小:284k
文件大小:2k
源码类别:
语音合成与识别
开发平台:
Visual C++
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using SpeechLib;
- namespace tryreco
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SpRecognition cc = new SpRecognition();
- cc.BeginRec(textBox1);
- }
- private void button2_Click_1(object sender, EventArgs e)
- {
- SpRecognition cc = new SpRecognition();
- cc.CloseRec();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- SpVoiceClass voice = new SpVoiceClass();
- voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(3);
- voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault); ;
- }
- private void button4_Click(object sender, EventArgs e)
- {
- SpeechVoiceSpeakFlags spFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
- SpVoice voice = new SpVoice();
- SaveFileDialog dialog = new SaveFileDialog();
- dialog.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
- dialog.Title = "保存WAV文件";
- dialog.FilterIndex = 2;
- dialog.RestoreDirectory = true;
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- SpeechStreamFileMode spFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
- SpFileStream spFileStream = new SpFileStream();
- spFileStream.Open(dialog.FileName, spFileMode, false);
- voice.AudioOutputStream = spFileStream;
- voice.Speak(textBox1.Text, spFlags);
- voice.WaitUntilDone(1000);
- //上面两句一定要写上,否则产生的文件没有声音
- //WaitUntilDone的后面的smTimeout是一个int型
- spFileStream.Close();
- }
- }
- }
- }