简体   繁体   English

需要设备识别

[英]Require on device recognition

有没有办法知道Swift下载语音模型需要多长时间?

Try using OSSSpeechKit .尝试使用OSSSpeechKit It works without a model.它在没有模型的情况下工作。 Here's the link: https://cocoapods.org/pods/OSSSpeechKit#speech-to-text .这是链接: https : //cocoapods.org/pods/OSSSpeechKit#speech-to-text

Example Code:示例代码:

import UIKit
import OSSSpeechKit

class ViewController: UIViewController, OSSSpeechDelegate {
    
    let speechKit = OSSSpeech.shared
    
    func didCompleteTranslation(withText text: String) {
        textView.text = text
        
    }
    
    func didFailToProcessRequest(withError error: Error?) {
        let alert = UIAlertController(title: "Error Processing Request", message: "We couldn't process your request.", preferredStyle: .alert)
        let action = UIAlertAction(title: "OK", style: .default)
        alert.addAction(action)
        present(alert, animated: true) {
            self.speechKit.endVoiceRecording()
            self.endButton.isHidden = true
            self.startButton.isHidden = false
        }
        
    }
    
    
    func didFinishListening(withText text: String) {
        textView.text = text
        
    }
    
    func authorizationToMicrophone(withAuthentication type: OSSSpeechKitAuthorizationStatus) {
        
    }
    
    func didFailToCommenceSpeechRecording() {
        let alert = UIAlertController(title: "Error Accessing the Microphone", message: "Make sure to check that you have given the app access to your microphone.", preferredStyle: .alert)
        let action = UIAlertAction(title: "OK", style: .default)
        alert.addAction(action)
        present(alert, animated: true) {
            self.speechKit.endVoiceRecording()
            self.endButton.isHidden = true
            self.startButton.isHidden = false
        }
        
    }
    
    @IBOutlet weak var textView: UITextView!
    
    @IBOutlet weak var startButton: UIButton!
    
    @IBOutlet weak var endButton: UIButton!
    
    @IBAction func startButtonPressed(_ sender: UIButton) {
        startButton.isHidden = true
        endButton.isHidden = false
        speechKit.recordVoice()
        
    }
    
    @IBAction func endButtonPressed(_ sender: UIButton) {
        endButton.isHidden = true
        startButton.isHidden = false
        speechKit.endVoiceRecording()
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        speechKit.delegate = self
        endButton.isHidden = true
        
    }

}

I'm pretty sure this'll work.我很确定这会奏效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 语音识别在此设备中不可用 - Speech recognition is not available in this device 设备上的语音识别是一回事吗? - is on-device speech recognition a thing? 语音识别物联网设备的推荐硬件 - Recommended hardware for speech recognition IoT device android设备中没有安装google的语音识别 - speech recognition without google installed in android device 使用.NET Framework的语音识别是否需要消息泵? - Does Speech Recognition using .NET Framework require a message pump? 未处理AudioException /语音识别程序中的音频设备错误 - AudioException was unhandled / Audio device error in speech recognition program 如何在我的Nexus 5设备上使用其他语音识别服务? - How to use other speech recognition service on my Nexus 5 device? 我会为语音识别选择什么设备来使用我的计算机发出的音频? - What device I would select for Speech Recognition to use the audio coming out of my computer? 语音识别(使用ML?),而不是语音识别 - Voice Recognition (with ML?), not Speech Recognition Microsoft语音识别中的数字识别 - Numbers Recognition in Microsoft Speech Recognition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM