我尝试为watchOS导入SpeechKit框架,但收到一个错误。有没有办法把它和手表一起使用?当我导入Speechkit框架时,我收到一个错误,说“没有这样的模块语音”。
import WatchKit
import Foundation
import Speech
class SpeechInterfaceController: WKInterfaceController, SFSpeechRecognizerDelegate {
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}}
发布于 2017-01-13 04:33:15
Speech框架不在watchOS开发工具包中(至少在watchOS 3.0-3.1版本中)。您可以看到这个in the framework docs

(如果它支持watchOS、tvOS或macOS,这些将列在该页面的SDK下。)
您还可以在Xcode SDK中查看可用的框架集:查看Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.1.sdk/System/Library/Frameworks/,或者在查看watchOS系统头文件的ObjC版本时查看Xcode编辑器窗格顶部的跳转栏,或者在手动添加到项目的WatchKit扩展目标的链接框架和库时查看可用选项列表。
发布于 2017-01-13 02:43:11
watchOS 3不支持SpeechKit框架。
要在手表应用程序中获得语音识别功能,您可以使用:
presentTextInputController(withSuggestions: nil, allowedInputMode: .plain) { (results) in
if let results = results?.first as? String {
self.label.setText(results)
}
}https://stackoverflow.com/questions/39657240
复制相似问题