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.MessageBegin();
- cc.BeginRec(textBox1); //Fan:把内容输入textbox1
- }
- private void button2_Click_1(object sender, EventArgs e)
- {
- SpRecognition cc = new SpRecognition();
- cc.MessageEnd();
- 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) //把语音转化成 .wav格式
- {
- //Declare the SpVoice object.
- ISpeechVoice v = new SpVoiceClass();
- //Create a wave stream
- SpFileStream s = new SpFileStream();
- //Create a new .wav file for writing.
- s.Open("out.wav", SpeechStreamFileMode.SSFMCreateForWrite, false);
- //Set the .wav file stream as the output for the Voice object
- v.AudioOutputStream = s;
- //Call the Speak method now will send the output to the .wav file.
- v.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault);
- //Close the file
- s.Close();
- }
- private void button5_Click(object sender, EventArgs e)
- {
- Speach Hunhe = new Speach();
- Hunhe.AnalyseSpeak(textBox1.Text);
- }
- }
- }