---
title: "一个基于c#3.0的开发基于vista下语音朗读的通用类"
author: "winzenghua"
date: "2009-01-12T21:09:00Z"
tags: []
slug: "c-3-0-vista"
draft: false
lastmod: "2009-01-12T21:09:00Z"
id: 948165
url: "https://java4gis.iteye.com/blog/948165"
---

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

namespace [yincheng01@163.com](mailto: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