在 iOS 7+ 的 UIWebView 中使用语音合成 API 设置速率、音高、音量
Setting rate, pitch, volume with speechSynthesis API in UIWebView for iOS 7+
我正在尝试使用UIWebView在我的iOS应用程序中执行一些简单的TTS(文本到语音转换)。据我了解,iOS 7 WebKit现在支持它,因此以下工作如下:
- (void) speakThis: (NSString*) text {
[webview stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:
@"speechSynthesis.speak(new SpeechSynthesisUtterance('"%@'"));",
text]];
}
但是,我还想在javascript中设置语速,音高和音量。我将如何在一条简单的行中做到这一点。
我知道我可以设置如下属性:
var speech = new SpeechSynthesisUtterance();
speech.text = "Hello";
speech.volume = 1; // 0 to 1
speech.rate = 1; // 0.1 to 9
speech.pitch = 1; // 0 to 2, 1=normal
speech.lang = "en-US";
speechSynthesis.speak(speech);
但是我想在我打电话时在一个初始化中传递音高、音量和速率
new SpeechSynthesisUtterance(")
有人,请协助吗?
你不需要使用 UIWebView。我只是在调查这个,并找到了 API 文档:https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVSpeechSynthesizer_Ref/Reference/Reference.html#//apple_ref/occ/cl/AVSpeechSynthesizer
相关文章:
- 使用Facebook live API创建实时视频对象时的隐私设置
- Twitter API在jQuery AJAX中设置授权头
- 使用谷歌地图api计算距离并将其设置在表格中<td>
- 使用Google'设置ID属性;s映射API
- 使用HTML5 Navigation Timing API时,导航开始时间设置为0
- 网络音频API,设置高音和低音
- 无法在系列中为 Highstock API 设置单个点颜色,它适用于 Highchart API
- 在NW.js应用程序中为HTML5文件API设置配额
- 使用 YouTube 直播 API 设置提取设置
- 使用 Web 音频 API 设置侦听器方向
- 使用 API javascript 设置 AngularJS 模板
- 选择数组的随机元素来设置Youtube视频ID API
- 谷歌图表API:设置表格列宽以适应数据
- 设置快速路由,找不到API调用返回404
- SoundCloud API:在audiomanager.js上设置音量
- Wistia Javascript API-设置视频泡沫真实和隐藏社交按钮
- 在谷歌地图API中设置邮政编码边界
- 如何在Google Maps JavaScript API中设置API key
- 如何在我的Google Apps Script API和我的esendex.com推送通知程序之间设置API中继
- 如何在backbone.js中设置API路径