有时我有一个像#12543这样的数字,我希望合成器显示“数字1-2-5-4-3”。
其他时候,我希望合成器显示“一万二千五百四十三”。
在座的任何人都知道System.Speech中是什么机制控制这些数字的发音吗?
发布于 2014-12-24 11:12:08
查看SayAs枚举和AppendTextWithHint方法,此示例基于微软文档。
using System;
using System.Speech.Synthesis;
namespace ConsoleApplication66
{
class Program
{
static void Main(string[] args)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
PromptBuilder talk = new PromptBuilder();
talk.AppendText("#12543");
talk.AppendTextWithHint("#12543", SayAs.SpellOut);
talk.AppendTextWithHint("#12543", SayAs.NumberOrdinal);
talk.AppendTextWithHint("#12543", SayAs.NumberCardinal);
synth.Speak(talk);
}
}
}https://stackoverflow.com/questions/27630739
复制相似问题