OGeek|极客世界-中国程序员成长平台

标题: ios - 使用 AVAudioEngine 录制麦克风时如何检测用户停止说话? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:04
标题: ios - 使用 AVAudioEngine 录制麦克风时如何检测用户停止说话?

我使用AVAudioEngine记录用户说话,我想实现当用户暂停或停止说话超过X秒时,将播放刚刚录制的句子。

但是如何在录制过程中检测到这种谈话暂停?还没有在 AVAudioEngine 中找到有用的 API,有什么想法可以帮助我吗?



Best Answer-推荐答案


你可以在里面设置定时器

private let speechRecognizer = SFSpeechRecognizer(locale: Locale.init(identifier: "en-US"))!    speechRecognizer.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in         

}) 堵塞。 在调用 speechRecognizer.recognitionTask 时设置开始时间,并在计时器内的每个后续请求后检查当前时间与开始时间之间的差异。如果差异高于 X 秒,请做任何你想做的事情.

关于ios - 使用 AVAudioEngine 录制麦克风时如何检测用户停止说话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42479336/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4