有没有办法在离线模式下使用 iOS 语音识别?

Is there a way to use iOS speech recognition in offline mode?

我想知道是否有办法在离线模式下使用 iOS 语音识别。根据文档 (https://developer.apple.com/reference/speech),我没有看到任何相关信息。

恐怕没有办法去做(但是,请务必在答案末尾检查更新).

Speech Framework Official Documentation 所述:

Best Practices for a Great User Experience:

Be prepared to handle the failures that can be caused by reaching speech recognition limits. Because speech recognition is a network-based service, limits are enforced so that the service can remain freely available to all apps.


从最终用户的角度来看,尝试在不连接到网络的情况下获得 Siri 的 帮助应该会显示类似以下的屏幕:

此外,当尝试发送消息时(例如),您会注意到如果设备未连接到网络,则麦克风按钮应该被禁用。

自然地,iOS 本身在检查网络连接之前无法使用此功能,我假设 third-party 开发人员在使用语音框架时也是如此。


更新:

看完Speech Recognition API Session(尤其是03:00 - 03:25部分),我想出了:

语音识别API通常需要互联网连接,但有些新设备确实支持此功能时间;您可能想检查给定的语言是否可用。

改编自SFSpeech​Recognizer Documentation

Note that a supported speech recognizer is not the same as an available speech recognizer; for example, the recognizers for some locales may require an Internet connection. You can use the supported​Locales() method to get a list of supported locales and the is​Available property to find out if the recognizer for a specific locale is available.


进一步阅读:

这些主题可能是相关的:

离线转录将从 iOS 13 开始可用。您可以使用 requiresOnDeviceRecognition 启用它。

示例代码 (Swift 5):

// Create and configure the speech recognition request.
recognitionRequest = SFSpeechAudioBufferRecognitionRequest()
guard let recognitionRequest = recognitionRequest else { fatalError("Unable to create a SFSpeechAudioBufferRecognitionRequest object") }
recognitionRequest.shouldReportPartialResults = true

// Keep speech recognition data on device
if #available(iOS 13, *) {
    recognitionRequest.requiresOnDeviceRecognition = true
}