我正在制作一个简单的应用程序,它可以从网站获取RSS提要,然后自动大声读取标题(文本到语音),所以我按照本教程创建了RSS阅读器https://msdn.microsoft.com/library/windows/apps/hh487167(v=vs.105).aspx
现在我不知道如何在列表框中自动发短信讲话新闻,有什么想法吗?
您可以简单地从msdn中获取TTS
api,但要确保在AppManifest
中启用ID_CAP_SPEECH_RECOGNITION
。
看看这里的样品。
更多信息:语音识别到文本Windows Phone 8
所以我想明白了,这是代码:
private void UpdateFeedList(string feedXML)
{
// Load the feed into a SyndicationFeed instance.
StringReader stringReader = new StringReader(feedXML);
XmlReader xmlReader = XmlReader.Create(stringReader);
SyndicationFeed feed = SyndicationFeed.Load(xmlReader);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
// Bind the list of SyndicationItems to our ListBox.
feedListBox.ItemsSource = feed.Items;
loadFeedButton.Content = "Refresh Feed";
feedListBox.SelectionMode = SelectionMode.Multiple;
feedListBox.SelectAll();
});
}
// The SelectionChanged handler for the feed items
private void feedListBox_SelectionChanged(object sender, RoutedEventArgs e)
{
ListBox listBox = sender as ListBox;
if (listBox != null && listBox.SelectedItem != null)
{
// Get the SyndicationItem that was tapped.
SyndicationItem sItem = (SyndicationItem)listBox.SelectedItem;
synth.SpeakTextAsync(sItem.Title.Text);
if (feedListBox.SelectedIndex < feedListBox.Items.Count - 1)
{
feedListBox.SelectedIndex = feedListBox.SelectedIndex + 1;
}
我很确定有更好的解决方案,但这起到了作用!