Skip to content

Commit

Permalink
Merge pull request #287 from loopandlearn/speech-number-formatting
Browse files Browse the repository at this point in the history
Replace commas with periods in speech output
  • Loading branch information
marionbarker authored Apr 28, 2024
2 parents dd6af43 + 82d0353 commit bf42d55
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions LoopFollow/Controllers/Alarms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1007,21 +1007,21 @@ extension MainViewController {
let texts = AnnouncementTexts.forLanguage(preferredLanguage)

let negligibleThreshold = 3
let absoluteDifference = bgUnits.toDisplayUnits(String(abs(bloodGlucoseDifference)))
let localizedCurrentValue = bgUnits.toDisplayUnits(String(currentValue)).replacingOccurrences(of: ",", with: ".")
let announcementText: String

if abs(bloodGlucoseDifference) <= negligibleThreshold {
announcementText = "\(texts.currentBGIs) \(bgUnits.toDisplayUnits(String(currentValue))) \(texts.stable)"
announcementText = "\(texts.currentBGIs) \(localizedCurrentValue) \(texts.stable)"
} else {
let directionText = bloodGlucoseDifference < 0 ? texts.decrease : texts.increase
announcementText = "\(texts.currentBGIs) \(bgUnits.toDisplayUnits(String(currentValue))) \(directionText) \(absoluteDifference)"
let absoluteDifference = bgUnits.toDisplayUnits(String(abs(bloodGlucoseDifference))).replacingOccurrences(of: ",", with: ".")
announcementText = "\(texts.currentBGIs) \(localizedCurrentValue) \(directionText) \(absoluteDifference)"
}

let speechUtterance = AVSpeechUtterance(string: announcementText)
speechUtterance.voice = AVSpeechSynthesisVoice(language: voiceLanguageCode)

speechSynthesizer.speak(speechUtterance)

}

func isOnPhoneCall() -> Bool {
Expand Down

0 comments on commit bf42d55

Please sign in to comment.