目标是能够发音像wo3。 System.Speech可以处理汉字,但有没有办法直接输入拼音?从http://msdn.microsoft.com/en-us/library/ms720566(v=vs.85).aspx来看,我应该能够像这样写出拼音
<PRON SYM="ni 3"/>
如何使用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\"/>");
}
答案 0 :(得分:5)
我已经做了这个例子,它工作正常,我不会说中文,所以,我使用自动翻译来获取样本字。
以下是表单的设计:
这是它背后的代码;我从中文音素表中得到了音素。
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);
}
}
}
}
在测试之前,请务必从ComboBox中选择(Microsoft简体中文)。如果您没有,可以下载Microsoft Speech语言包(SpeechSDK51LangPack.exe)。
修改强>
在SpeechSynthesizer中= = =音素和sym =&gt; 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);
}
答案 1 :(得分:0)
答案 2 :(得分:0)
我认为你的例子需要稍加修改......
if (voices.Count > 0)
{
synth.SelectVoice(voices[0].VoiceInfo.Name);
PromptBuilder pb = new PromptBuilder();
pb.AppendSsml("<pron sym=\"ni 3 hao 3 xiao 1\"/>");
synth.Speak(pb);
}