VíctorVarLed
VíctorVarLed

Reputation: 148

Get current speed of VoiceOver on iOS

Is there any way to get the current speed of the VoiceOver speech on an iOS app? Sometimes I use my own AVSpeechUtterance strings and I'd like to use the same rate that's is configured on VoiceOver settings. Thanks in advance.

Upvotes: 8

Views: 738

Answers (2)

Augustin Monfret
Augustin Monfret

Reputation: 11

If you want to use AVSpeechUtterance with VoiceOver settings, you can use this parameter prefersAssistiveTechnologySettings since iOS 14*

let utterance = AVSpeechUtterance(string: "Hello world !")
utterance.prefersAssistiveTechnologySettings = true

Note that it will use the VoiceOver settings only if VoiceOver is activated when the utterance is called.

From apple documentation for this parameter:

If an assistive technology is on, like VoiceOver, the user's selected voice, rate and other settings will be used for this speech utterance instead of the default values. If no assistive technologies are on, then the values of the properties on AVSpeechUtterance will be used. Note that querying the properties will not refect the user's settings.

So you do not have access directly to the user settings but you can still use them.

Upvotes: 1

jl303
jl303

Reputation: 1609

Is the announcement specifically for VoiceOver users? Then it might be better to post announcement notification from UIAccessibility. VoiceOver will announce the notification, so users will hear with the same voice and speed from their VoiceOver setting.

UIAccessibility.post(notification:.announcement, argument:"Hello World!")

Read more information from the documentation.

UIAccessibility.post: https://developer.apple.com/documentation/uikit/uiaccessibility/1615194-post

UIAccessibility.Notification: https://developer.apple.com/documentation/uikit/uiaccessibility/notification

announcement: https://developer.apple.com/documentation/uikit/uiaccessibility/notification/1620176-announcement

Upvotes: 3

Related Questions