标签:auto 需要 源码 ring keyword tps element htm www
原文:UWP-电子音读出文字源码: https://github.com/lindexi/Markdown
代码
private async void speech(string str, MediaElement media_element)
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
SpeechSynthesisStream stream = await synthesizer.SynthesizeTextToStreamAsync(str);
media_element.SetSource(stream, stream.ContentType);
media_element.Play();
}
实例化SpeechSynthesizer,使用SynthesizeTextToStreamAsync把文本变为流
可以使用MediaElement播放,MediaElement播放需要把流和格式放到MediaElement
media_element.Play();
<MediaElement Grid.Row=“0” x:Name=“mediaelement” AutoPlay=“True” Volume=“1.0” />
Volume 声音
参考:http://www.cnblogs.com/tcjiaan/
标签:auto 需要 源码 ring keyword tps element htm www
原文地址:http://www.cnblogs.com/lonelyxmas/p/7559690.html