基于此 WWDC2018 video ,我们可以动态改变单词在 AVSpeechSynthesizer
中的发音方式.
我正在尝试在我的 Xamarin 应用程序中执行此操作,但找不到 accessibilitySpeechIPANotation
持续的。
在 NSMutableAttributedString.AddAttribute(...)
的文档中它说可以在这里找到常量:UIKit.UIStringAttributeKey
.然而我要找的那个不在那里。
有谁知道常量的实际字符串值是多少?或者甚至更好,我可以在 Xamarin.iOS 中找到?
(我的应用程序使用 xamarin.ios v4.0.30319,如果常量在框架的较新版本中,我会更新它,但是当我搜索它时,google 似乎没有给我任何结果。)
最佳答案
原因:
Xamarin for iOS 是基于 Objective-C 的,swift 和 Objective-C 有一些区别。
解决方案:
代码如下:
var attriStrng = new NSMutableAttributedString(new NSString("hello iPhone"));
// you can set the voice here ,a͡͡a͡͡a͡͡a͡͡a͡͡ is just for testing
attriStrng.AddAttribute(new NSString("AVSpeechSynthesisIPANotationAttribute"), new NSString("ˈa͡͡a͡͡a͡͡a͡͡a͡͡a͡͡a͡͡.ˈfo͡ʊn"),new NSRange(6,6));
var voice = new AVSpeechUtterance(attriStrng);
AVSpeechSynthesizer synthesizer = new AVSpeechSynthesizer();
synthesizer.SpeakUtterance(voice);
关于xamarin - iOS 的accessibilitySpeechIPANotation 的值(value)是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54412952/