Bug 258587

Summary: Web speech: mapSpeechRateToPlatformRate exceeds AVSpeechUtteranceMaximumSpeechRate
Product: WebKit Reporter: Avi Drissman <avi>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: jer.noble, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Avi Drissman 2023-06-27 13:15:45 PDT
https://github.com/WebKit/WebKit/blob/fca03d0dccb29ce539876bba8d7180f93ecc12b9/Source/WebCore/platform/cocoa/PlatformSpeechSynthesizerCocoa.mm#L96:

    // WebSpeech says to go from .1 -> 10 (default 1)
    // AVSpeechSynthesizer asks for 0 -> 1 (default. 5)
    if (rate < 1)
        rate *= AVSpeechUtteranceDefaultSpeechRate;
    else
        rate = AVSpeechUtteranceDefaultSpeechRate + ((rate - 1) * (AVSpeechUtteranceMaximumSpeechRate - AVSpeechUtteranceDefaultSpeechRate));

This maps the slower rates linearly from AVSpeechUtteranceMinimumSpeechRate to AVSpeechUtteranceDefaultSpeechRate. However, while this maps

1 → AVSpeechUtteranceDefaultSpeechRate

it maps

10 → 0.5 + ((10-1)*.5) = 0.5 + 4.5 = 5

and 5 is significantly larger than AVSpeechUtteranceMaximumSpeechRate (1).

Is it intentional to pass a speech rate higher than the maximum?
Comment 1 Radar WebKit Bug Importer 2023-06-27 14:04:33 PDT
<rdar://problem/111411189>
Comment 2 Avi Drissman 2023-06-27 14:40:09 PDT
I’m switching Chromium from NSSpeechSynthesizer to AVSpeechSynthesizer. I’m scaling differently, FYI: https://chromium-review.googlesource.com/c/chromium/src/+/4638862