Search code examples
iosios13sirikitsfspeechrecognizer

Does SFSpeechRecognizer have a limit if supportsOnDeviceRecognition is true and offline mode is available?


According to the Apple documents, there is a limit to the number of requests that SFSpeechRecognizer can send.

Be prepared to handle failures caused by 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. Individual devices may be limited in the number of recognitions that can be performed per day, and each app may be throttled globally based on the number of requests it makes per day. If a recognition request fails quickly (within a second or two of starting), check to see if the recognition service became unavailable. If it is, you may want to ask users to try again later. https://developer.apple.com/documentation/speech/sfspeechrecognizer

Another document says that a device can send 1000 requests per hour.

The current rate limit for the number of SFSpeechRecognitionRequest calls a device can make is 1000 requests per hour. Please note this limit is on the number of requests that a device can make and is not tied to the application making it. This is regardless of the length of audio associated with the request. For a given SFSpeechRecognitionRequest, you are allowed up to one minute of audio per request.

Now I am creating a SFSpeechRecognizer as shown below and check the supportsOnDeviceRecognition property that indicates whether the speech recognizer can operate without network access. It returns true on my iOS 13.2.3 installed device.

let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!
print(speechRecognizer.supportsOnDeviceRecognition) //true

I have tried to run my application offline and it works fine without an internet connection. But there is no information if there is still a request limit or not if supportsOnDeviceRecognition is true. In this situation, SFSpeechRecognizer probably won't connect to the Apple servers even if the device is connected to the internet because it would be unnecessary. Is the rate limit only when supportsOnDeviceRecognition is true?


Solution

  • According to this presentation at the WWDC2019, On-device has no limits.

    https://developer.apple.com/videos/play/wwdc2019/256/

    WWDC2019