- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在开发一个使用 AVSynthesizer 将文本转换为语音的 iOS 应用程序。
我想要做的是,当合成器在说话时,可以通过 slider 改变发声率,并且说话的速度会发生变化。
我在 slider 的 IBAction 中执行此操作:
self.utterance = sender.value
但合成器不会改变速度。我一直在寻找信息,但我还没有找到任何东西。
我能做什么?提前致谢。
最佳答案
好的,所以在玩了一些我不知道的很酷的功能之后,我找到了一种改变说话速度的方法。主要问题是话语当前被合成器排入队列,rate
无法更改。对应文档:
/* Setting these values after a speech utterance has been enqueued will have no effect. */
open var rate: Float // Values are pinned between AVSpeechUtteranceMinimumSpeechRate and AVSpeechUtteranceMaximumSpeechRate.
open var pitchMultiplier: Float // [0.5 - 2] Default = 1
open var volume: Float // [0-1] Default = 1
import UIKit
import AVFoundation
class ViewController: UIViewController {
var synthesizer: AVSpeechSynthesizer!
var string: String!
var currentRange: NSRange = NSRange(location: 0, length: 0)
@IBAction func sl(_ sender: UISlider) {
synthesizer.stopSpeaking(at: .immediate)
if currentRange.length > 0 {
let startIndex = string.index(string.startIndex, offsetBy: NSMaxRange(currentRange))
let newString = string.substring(from: startIndex)
string = newString
synthesizer.speak(buildUtterance(for: sender.value, with: string))
}
}
func buildUtterance(for rate: Float, with str: String) -> AVSpeechUtterance {
let utterance = AVSpeechUtterance(string: str)
utterance.rate = rate
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
return utterance
}
override func viewDidLoad() {
super.viewDidLoad()
string = "I am currently developing an iOS app that converts text to speech using AVSynthesizer.What I want to do is that while the synthesizer is speaking, utterance rate can be changed and with a slider and the speed of the speaking changes. I am doing this in the IBAction of the slider: self.utterance = sender.value but the synthesizer doesn't change the speed. Ive been looking for information but I haven't found something yet. What can I do? Thanks in advance."
synthesizer = AVSpeechSynthesizer()
synthesizer.delegate = self
synthesizer.speak(buildUtterance(for: AVSpeechUtteranceDefaultSpeechRate, with: string))
}
}
extension ViewController: AVSpeechSynthesizerDelegate {
func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, willSpeakRangeOfSpeechString characterRange: NSRange, utterance: AVSpeechUtterance) {
debugPrint(characterRange.toRange())
currentRange = characterRange
}
}
willSpeakRangeOfSpeechString
的 AVSpeechSynthesizerDelegate
并将合成器的委托(delegate)定义为自我:synthesizer.delegate = self
IBAction func sl(_ sender: UISlider)
到 slider 的事件 touchUpInside。 关于ios - 实时更改 AVSpeechUtterance 速率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44507250/
我需要一次发送至少 200 条消息。程序启动后,给15或17发邮件成功,然后报错: 消息错误: com.sun.mail.smtp.SMTPSendFailedException: 421 4.4.2
我目前正在开发一个使用 AVSynthesizer 将文本转换为语音的 iOS 应用程序。 我想要做的是,当合成器在说话时,可以通过 slider 改变发声率,并且说话的速度会发生变化。 我在 sli
假设我们有以下场景: 包含 10,000 条消息的服务总线队列 Azure Functions(使用计划),其中函数设置为 SB 队列的触发器 外部(不受我们控制)系统无法超过特定请求率 如果我尽快对
TextToSpeech有设置语速的方法:setSpeechRate() .但它没有查询当前速度的相反方法。 有没有办法向系统查询该值? 最佳答案 您可能会得到默认的 TTS 语速 Settings.
我有一个关于 NGINX 速率限制的问题。 是否可以根据 JWT token 的解码值进行速率限制?我在文档中找不到任何这样的信息。 或者即使有一种通过创建纯自定义变量(使用 LuaJIT)来进行速率
我有一个带有方向键和 2 个按钮的游戏 handle 。所有这些都是数字的(不是模拟的)。 我有一个处理他们的事件的程序: -(void)gamepadTick:(float)delta {
所以我需要在 OpenCV 中获取网络摄像头的 fps 速率。哪个功能可以做这样的事情? 最佳答案 int cvGetCaptureProperty( CvCapture* capture, int
我四处寻找 CURL 设置文件,但没有在/etc/中找到它,也没有在 curl 站点 ether 上找到太多... 所以基本上我想做的是设置 curl 可以上传的最大速度限制(无论它正在运行多少个实例
我有一个在 Atom 上运行的嵌入式 Linux 系统,这是一个足够新的 CPU,可以有一个不变的 TSC(时间戳计数器),内核在启动时测量其频率。我在自己的代码中使用 TSC 来保持时间(避免内核调
我正在寻找一种以高粒度单独限制 RPC 速率的方法,令我沮丧的是,针对此问题可用的选项并不多。我正在尝试用 gRPC 替换 REST API,对我来说最重要的功能之一是能够为每个路由添加中间件。不幸的
我正在使用 PHP、MySQL 和 Redis 开发 API,并希望对特定调用进行速率限制。 API 位于 CloudFlare 后面。为实现这一点,我将增加每个 IP 地址每小时在 Redis 中进
我正在寻找一种以编程方式(无论是调用库还是独立程序)监视 linux 中实时 ip 流量的方法。我不想要总数,我想要当前正在使用的带宽。我正在寻找与 OS X 的 istat 菜单的网络流量监视器类似
所以我注意到 Apple 更改了 SKStoreProductViewController,禁用了“写评论”按钮。此问题是否有任何解决方法或修复方法? 最佳答案 SKStoreProductViewC
我今天浏览了 Amazon RDS 定价网站,现在确实想知道他们实际上如何计算 I/O 速率? “每 100 万个请求 0.10 美元”到底是什么意思? 谁能举出一些简单的例子,从 EC2 到 RDS
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 5 年前。 Improve
在旧的 API 中,剩余的允许容量显然作为 X-Ratelimit-Remaining 返回HTTP header 。 然而,current version's documentation对此一无所获
在我的 Android 应用程序中,我观察到前置摄像头录制的视频以 7-10 fps 的速度录制,而后置摄像头的工作正常, native 摄像头应用程序确实以 29fps 的速度录制前置摄像头的视频。
我正在编码一个里面有 dvb_teletext 的视频。打开输出流 #1:2 的编码器时出现错误提示。我使用以下命令对我的视频进行编码。 ffmpeg -threads 8 -i input.ts -
我正在使用以下命令为我的视频添加淡入淡出效果 {"-y", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, "-i",
我正在尝试使用以下命令通过 FFMPEG 将 avi 视频文件转换为 flv 格式: -i C:\files\input\test.avi -y -ab 448k -ar 48000 -vcodec
我是一名优秀的程序员,十分优秀!