Google 文字转语音无法使用 C# Android
Google text to speech not working C# Android
我正在使用 google 文本语音通过单击按钮将我的文本转换为语音,当我手动设置文本时它工作正常
var textview = FindViewById<TextView>(Resource.Id.textView);
textview.Text = "anuthing to speak";
但是当我从以下函数设置 textview 文本时,它什么也没说
public string CovertChapterToText(EpubChapter chapter)
{
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(chapter.HtmlContent);
StringBuilder sb = new StringBuilder();
foreach (HtmlNode node in htmlDocument.DocumentNode.SelectNodes("//text()"))
{
sb.AppendLine(node.InnerText.Trim());
}
string chapterText = sb.ToString();
return chapterText;
}
喜欢
textview.Text = CovertChapterToText(chapterToBeShown);
按钮点击事件
btnSpeak.Click += delegate {
// if there is nothing to say, don't say it
if (!string.IsNullOrEmpty(textview.Text))
textToSpeech.Speak(textview.Text, QueueMode.Flush, null);
};
不知道为什么。但是 google tts 不会读取屏幕外的文本。当我从末尾删除一些字符时,它开始像魅力一样工作
我正在使用 google 文本语音通过单击按钮将我的文本转换为语音,当我手动设置文本时它工作正常
var textview = FindViewById<TextView>(Resource.Id.textView);
textview.Text = "anuthing to speak";
但是当我从以下函数设置 textview 文本时,它什么也没说
public string CovertChapterToText(EpubChapter chapter)
{
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(chapter.HtmlContent);
StringBuilder sb = new StringBuilder();
foreach (HtmlNode node in htmlDocument.DocumentNode.SelectNodes("//text()"))
{
sb.AppendLine(node.InnerText.Trim());
}
string chapterText = sb.ToString();
return chapterText;
}
喜欢
textview.Text = CovertChapterToText(chapterToBeShown);
按钮点击事件
btnSpeak.Click += delegate {
// if there is nothing to say, don't say it
if (!string.IsNullOrEmpty(textview.Text))
textToSpeech.Speak(textview.Text, QueueMode.Flush, null);
};
不知道为什么。但是 google tts 不会读取屏幕外的文本。当我从末尾删除一些字符时,它开始像魅力一样工作