tof*_*tim 13 c# sapi text-to-speech cjk
目标是能够发音像wo3.System.Speech可以处理汉字,但有没有办法直接输入拼音?从http://msdn.microsoft.com/en-us/library/ms720566(v=vs.85).aspx看来,我应该能够像这样写出拼音
<PRON SYM="ni 3"/>
Run Code Online (Sandbox Code Playgroud)
我如何使用PRON SYM?
更新: 以下是一些讨论该问题但没有解决方案的网页: - http://www.ms-news.net/f3012/problem-with-phonemes-and-chinese-tts-3031240.html
Update2 我在.NET中使用System.Speech.Synthesizer.也许这就是问题所在.我可以看到将它输入Speech Properties工作正常:

如果我从C#中执行此操作,它只会读取标记:
var culture = CultureInfo.GetCultureInfo("zh-CN");
var synth = new SpeechSynthesizer();
var voices = synth.GetInstalledVoices(culture);
if (voices.Count > 0)
{
synth.SelectVoice(voices[0].VoiceInfo.Name);
synth.Speak("<pron sym=\"ni 3 hao 3 xiao 1\"/>");
}
Run Code Online (Sandbox Code Playgroud)
我做了这个例子,它工作正常,我不会说中文,所以,我使用自动翻译来获取样本字.
这是表单的设计:

这是它背后的代码; 我从中文音素表中得到了音素.
using System;
using System.Windows.Forms;
using SpeechLib;
namespace SpeechDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//get installed voices
SpVoice voice = new SpVoice();
foreach (var item in voice.GetVoices())
{
comboBox1.Items.Add(((ISpeechObjectToken)item).GetDescription());
}
}
private void btnSpeakPhonems_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex > 0)
{
SpVoice voice = new SpVoice();
voice.Voice = voice.GetVoices().Item(comboBox1.SelectedIndex);
voice.Speak("<pron sym=\"ang 1 zang 1\">??</pron>", SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在测试之前,请务必从ComboBox中选择(Microsoft简体中文).如果没有,可以下载Microsoft Speech语言包(SpeechSDK51LangPack.exe).
编辑:
在SpeechSynthesizer中= = phoneme和sym => ph.这里的代码可以正常使用SpeechSynthesizer:
private void button1_Click(object sender, EventArgs e)
{
var cu = CultureInfo.GetCultureInfo("zh-CN");
SpeechSynthesizer sp = new SpeechSynthesizer();
var voices = sp.GetInstalledVoices(cu);
sp.SelectVoice(voices[0].VoiceInfo.Name);
string s = "<?xml version=\"1.0\"?> <speak version=\"1.0\" xml:lang=\"zh-CN\"><phoneme ph=\"ang 1 zang 1\">?</phoneme></speak>";
sp.SpeakSsml(s);
}
Run Code Online (Sandbox Code Playgroud)