xamarin - 我如何知道 Xamarin 中的文本转语音过程何时开始和结束
问题描述
我试图在 TTS 进程开始时添加动画(动画也开始),当 TTS 函数结束时,动画也结束。
我现在有这个作为我的代码:
if (!string.IsNullOrWhiteSpace(TTSEditor.Text))
{
animationView.Loop = true;
animationView.AutoPlay = true;
animationView.Play();
//insert TTS function Here
var Text = TTSEditor.Text;
CrossTextToSpeech.Current.Speak(Text, speakRate: (float)0.9, pitch: (float)1.1f);
}
else
{
DisplayAlert("Error", "Text Field Should not be Blank to Use Text-to-Speech Functionality!", "OK");
}
我使用 Xam.Plugins.TextToSpeech 作为我的 TTS,它工作正常,但我似乎无法在这里找到我想要的:https ://github.com/jamesmontemagno/TextToSpeechPlugin
解决方案
您可以等待发言过程:
private async void Button_Clicked(object sender, EventArgs e)
{
Console.WriteLine("begin");
await CrossTextToSpeech.Current.Speak("Hello world! Hello world! Hello world! Hello world!", speakRate: (float)0.9, pitch: (float)1.1f);
Console.WriteLine("end");
}
参考:编程指南/概念/异步
推荐阅读
- xamarin - 没有暴露给 Xamarin 的 Foundation.URL 结构?
- python - 在 Python 中正确保存/导入地理编码数据
- jquery - 如何使用 JQuery 将相同的输入值克隆到其他输入?
- java - 在不打开相机应用程序的情况下拍照
- laravel - 如何修剪 yajra 数据表中的字符串在 laravel 中使用原始查询
- methods - 制作一个改变方法中 x,y 值的函数
- android - 带有透明状态栏的全屏片段(以编程方式)
- python - AddModuloEquality 的反面
- generics - Groovy - 通用约束中的特征
- javascript - 为什么在控制台中打印 mongoose 的模型对象时会看到额外的字段。我正在将节点 JS 与猫鼬一起使用。我怎样才能隐藏这些属性