From e5731149ed2177538c988b5379160fba5d6212cc Mon Sep 17 00:00:00 2001 From: dwassmer <43072001+dwassmer@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:40:08 +0200 Subject: [PATCH] fix(ios)!: linear rate adjustment (#136) BREAKING CHANGE: The speech rate now has a linear behavior. --- ios/Plugin/TextToSpeech.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ios/Plugin/TextToSpeech.swift b/ios/Plugin/TextToSpeech.swift index 27b675f..dc11b63 100644 --- a/ios/Plugin/TextToSpeech.swift +++ b/ios/Plugin/TextToSpeech.swift @@ -68,14 +68,11 @@ import Capacitor // Adjust rate for a closer match to other platform. @objc private func adjustRate(_ rate: Float) -> Float { - let baseRate = AVSpeechUtteranceDefaultSpeechRate - if rate == 1 { - return baseRate - } - if rate > baseRate { - return baseRate + (rate * 0.025) - } - return rate / 2 + let baseRate: Float = AVSpeechUtteranceDefaultSpeechRate + if (rate >= 1.0 ) { + return (0.1 * rate) + (baseRate - 0.1) + } + return rate * baseRate } @objc private func resolveCurrentCall() {