ITeye博客

一个基于c#3.0的开发基于vista下语音朗读的通用类

winzenghua · 2009-01-12 21:09 · Markdown

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis;
using System.Speech;

namespace yincheng01@163.com
{
public class SpeechSpeak
{
public SpeechSynthesizer synth;
public SpeechSpeak()
{

synth = new SpeechSynthesizer();

}
// public SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;

public SpeechSpeak(int m, int n)
{

//使用 synth 设置朗读音量 [范围 0 ~ 100]
synth.Volume = m;
//使用 synth 设置朗读频率 [范围 -10 ~ 10]
synth.Rate = n;
}

public void SpeakChina(string ggg)
{

//SpVoice Voice = new SpVoice();
synth.SelectVoice("Microsoft Lili");

//Voice.Speak(ggg, SpFlags);
synth.SpeakAsync(ggg);

//String speechPeople = synth.Voice;
//使用 synth 设置朗读音量 [范围 0 ~ 100]
// synth.Volume = 80;
//使用 synth 设置朗读频率 [范围 -10 ~ 10]
// synth.Rate = 0;

//使用synth 合成 wav 音频文件:
//synth.SetOutputToWaveFile(string path);

}

public void SpeakEnglish(string ggg)
{

//SpVoice Voice = new SpVoice();
synth.SelectVoice("Microsoft Anna");

synth.Speak(ggg);

}
public int m
{
get
{
return synth.Volume;

}
set
{

synth.Volume = value;
}

}

public int n
{
get
{
return synth.Rate;

}
set
{

synth.Rate = value;
}

}

public void Pause()
{

synth.Pause();

}
public void Goon()
{

synth.Resume();

}
public void Cancel()
{

synth.SpeakAsyncCancelAll();
}
}
}

需要源码的请留下Email

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。