Repository Public License
1//2// ORIX Audio3// File: ORIXAudio/App/CoreText.swift4// Description: Localized wording for values and errors that come from ORIXAudioCore (the package itself is language-neutral).5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8//9import Foundation10import ORIXAudioCore1112enum CoreText {13 static func name(_ palette: Colormap) -> String {14 switch palette {15 case .orixSpectrum: String(localized: "ORIX Spectrum")16 case .scientific: String(localized: "Scientific")17 case .thermal: String(localized: "Thermal")18 case .monochrome: String(localized: "Monochrome")19 case .highContrast: String(localized: "High Contrast")20 case .colorblind: String(localized: "Colorblind-friendly")21 }22 }2324 static func name(_ window: WindowFunction) -> String {25 switch window {26 case .rectangular: String(localized: "Rectangular")27 case .flatTop: String(localized: "Flat Top")28 default: window.displayName // Hann, Hamming, Blackman, Blackman–Harris are proper names29 }30 }3132 static func name(_ scaling: SpectrumScaling) -> String {33 switch scaling {34 case .amplitude: String(localized: "Amplitude")35 case .power: String(localized: "Power")36 case .powerSpectralDensity: String(localized: "Power spectral density")37 }38 }3940 static func bandName(_ index: Int) -> String {41 switch index {42 case 0: String(localized: "Sub-bass")43 case 1: String(localized: "Bass")44 case 2: String(localized: "Low-mid")45 case 3: String(localized: "Mid")46 case 4: String(localized: "Upper-mid")47 case 5: String(localized: "Presence")48 default: String(localized: "Brilliance")49 }50 }5152 static func name(_ mode: ChannelMode) -> String {53 switch mode {54 case .original: String(localized: "Original")55 case .left: String(localized: "Left only")56 case .right: String(localized: "Right only")57 case .mono: String(localized: "Mono mix")58 }59 }6061 static func explain(_ availability: IntelligenceAvailability) -> String {62 switch availability {63 case .available: String(localized: "Summaries run on-device with Apple Foundation Models.")64 case .deviceNotEligible: String(localized: "This device doesn't support Apple Intelligence, so summaries, action items and transcript questions are unavailable. Recording, analysis and transcription work normally.")65 case .appleIntelligenceNotEnabled: String(localized: "Apple Intelligence is turned off. Turn it on in Settings to use summaries. Recording, analysis and transcription work normally.")66 case .modelNotReady: String(localized: "The on-device language model is still being prepared by the system. Try again later.")67 case .unavailable: String(localized: "The on-device language model isn't available right now.")68 }69 }7071 static func language(_ identifier: String) -> String { Locale.current.localizedString(forIdentifier: identifier) ?? identifier }7273 /// A user-facing sentence for any error raised by the engines.74 static func describe(_ error: Error) -> String {75 switch error {76 case let e as TranscriptionError:77 switch e {78 case .notAuthorized: return String(localized: "Speech recognition isn't authorised for ORIX Audio. You can allow it in Settings.")79 case .unsupportedLocale(let l): return String(localized: "On-device transcription isn't available for \(language(l)) on this device.")80 case .modelNotInstalled(let l): return String(localized: "The on-device speech model for \(language(l)) isn't installed. It must be downloaded once (this needs a network connection); audio is never uploaded.")81 case .onDeviceUnavailable(let l): return String(localized: "This device can't transcribe \(language(l)) on-device, and ORIX Audio never sends audio to a server.")82 case .failed(let m): return String(localized: "Transcription failed: \(m)")83 }84 case let e as IntelligenceError:85 switch e {86 case .unavailable(let a): return explain(a)87 case .emptyTranscript: return String(localized: "There is no transcript to work from yet.")88 case .refused: return String(localized: "The on-device model declined to process this content.")89 case .failed: return String(localized: "The on-device model couldn't complete the request. Try again; if it keeps failing, this device or simulator may not be able to run the model.")90 }91 case let e as AudioIOError:92 switch e {93 case .unreadable(let m): return String(localized: "This file can't be read as audio (\(m)).")94 case .noAudioTrack: return String(localized: "This file has no audio track.")95 case .unsupported(let m): return String(localized: "Unsupported: \(m).")96 case .cancelled: return String(localized: "Cancelled")97 case .writeFailed(let m): return String(localized: "The file couldn't be written (\(m)).")98 }99 default: return error.localizedDescription100 }101 }102}103