小编AMH*_*AMH的帖子

如何在Swift 4和IOS 11中更改语音识别语言?

我正在尝试使用UISegmentedControl更改UI中的语言,我想将其他实例作为ViewControler类的属性,例如

    private let speechRecognizer_en = SFSpeechRecognizer(locale: Locale.init(identifier: "en-US"))  //1

    private let speechRecognizer_fr = SFSpeechRecognizer(locale: Locale.init(identifier: "fr-BE"))  //1
Run Code Online (Sandbox Code Playgroud)

这是一种方法,但是可以肯定的是,我肯定不知道这是最好的方法。你们大家能给我一个更好的主意,我该怎么办?

这是应用程序源代码,我们可以输入用户曾经用英语说的内容,但我们希望为用户提供更改语言的选项:

import UIKit
import Speech

class ViewController: UIViewController {

@IBOutlet weak var segView: UISegmentedControl!
@IBOutlet weak var startStopBtn: UIButton!
@IBOutlet weak var textView: UITextView!

private Let speechRecognizer = SFSpeechRecognizer(locale: Locale.init(identifier: "en-US"))  //1
private Let recognitionRequest: SFSpeechAudioBufferRecognitionRequest?
private Let recognitionTask: SFSpeechRecognitionTask?
private Let audioEngine = AVAudioEngine()

override func viewDidLoad() {
    super.viewDidLoad()

    startStopBtn.isEnabled = false  //2

    speechRecognizer?.delegate = self as? SFSpeechRecognizerDelegate  //3

    SFSpeechRecognizer.requestAuthorization { …
Run Code Online (Sandbox Code Playgroud)

speech-recognition speech ios swift

3
推荐指数
1
解决办法
977
查看次数

我们如何在 Swift 4+ 和 IOS 11+ 中录制和保存视频?

我正在尝试录制视频,然后将其保存在 IOS 设备上,我可以录制它,但我想知道如何将其保存在设备上?

import UIKit
import AVKit
import MobileCoreServices

class ViewController: UIViewController , UIImagePickerControllerDelegate , UINavigationControllerDelegate {
    @IBOutlet weak var RecordButton: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    @IBAction func RecordAction(_ sender: UIButton) {

        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
            print("Camera Available")

            let imagePicker = UIImagePickerController()
            imagePicker.delegate = self
            imagePicker.sourceType = .camera
            imagePicker.mediaTypes = [kUTTypeMovie as String]
            imagePicker.allowsEditing = false

            self.present(imagePicker, animated: true, completion: nil)
        } else {
            print("Camera UnAvaialable") …
Run Code Online (Sandbox Code Playgroud)

video ios swift swift4 ios11

3
推荐指数
1
解决办法
4884
查看次数

为什么这个keyup事件处理程序不能在IE9中运行?

当我们按下它时,下面的代码中存在Keyup事件的错误,它适用于所有浏览器exets IE9你是否对此有所了解:

   // on 'enter' in any input field, do the search
$("input, select", _this.sbox).keyup(function(event) {
    if (event.keyCode == 13) _this.doSearch();
});
Run Code Online (Sandbox Code Playgroud)

javascript jquery

2
推荐指数
1
解决办法
1037
查看次数

标签 统计

ios ×2

swift ×2

ios11 ×1

javascript ×1

jquery ×1

speech ×1

speech-recognition ×1

swift4 ×1

video ×1