最近项目需要,需要使用C#开发一个简单的TTS服务器,用于响应客户端的tts请求。
本人对这块也不熟悉,需要人头开始搞,在网上找了一些资料,经过几天折腾终于搞出来了。
其实代码本身非常简单,核心代码也就几行而已,很多网站上都有贴出来,这里借花献佛也贴出来一下,不过有部分小改动。
先贴出代码吧:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis.TtsEngine;
using System.Speech.Synthesis;
using System.Speech.AudioFormat;
using System.IO;
namespace TTSServer
{
// 需要添加引用:System.Speech
class TTS
{
///
/// 获取系统已安装的声音信息
///
///
public static List
getVoiceInfos()
{
List
voiceList = new List
();
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
foreach (InstalledVoice voice in synth.GetInstalledVoices())
{
voiceList.Add(voice.VoiceInfo);
}
}
return voiceList;
}
///