xcode 简单的语音识别 Swift?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29570604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:57:33  来源:igfitidea点击:

Simple Voice Recognition Swift?

iosxcodeswiftvoice-recognitionvoice

提问by Junaid

In my app when the user says a certain word or words the app will answer by reading out a sentence which is set in app. What is the simplest way of doing this?

在我的应用程序中,当用户说出某个或多个单词时,应用程序将通过读出应用程序中设置的句子来回答。这样做的最简单方法是什么?

I'm using the latest version of Xcode (Its for my WWDC 2015 scholarship app)

我正在使用最新版本的 Xcode(用于我的 WWDC 2015 奖学金应用程序)

采纳答案by kavehmb

回答by fpg1503

As of iOS 10 you can use Speech.framework:

从 iOS 10 开始,您可以使用Speech.framework

import Speech

let recognizer = SFSpeechRecognizer()
let request = SFSpeechURLRecognitionRequest(url: audioFileURL)
recognizer?.recognitionTask(with: request, resultHandler: { (result, error) in
     print (result?.bestTranscription.formattedString)
})

回答by Oxcug

You'll want to use SpeechKit. Ray has a nice tutorial here:

你会想要使用SpeechKit. Ray在这里有一个很好的教程:

http://www.raywenderlich.com/60870/building-ios-app-like-siri

http://www.raywenderlich.com/60870/building-ios-app-like-siri

The SDK is developed by Nuance (the dragon people):

SDK由Nuance(龙人)开发:

http://nuancemobiledeveloper.com/public/index.php

http://nuancemobiledeveloper.com/public/index.php