74808f086e
* feat: Replace Legacy Media Controls with Nitro-Powered Playback * feat: Add TTS Engine Selection * chore: Remove User-Facing Error Reporting * refactor: Combine `Tts` and `TtsSession` Imports from `nitro-tts` Module --------- Co-authored-by: Claude <noreply@anthropic.com>
29 lines
931 B
Swift
29 lines
931 B
Swift
import AVFAudio
|
|
import NitroModules
|
|
|
|
final class HybridTtsFactory: HybridTtsFactorySpec {
|
|
func createSession() throws -> Promise<any HybridTtsSessionSpec> {
|
|
return Promise.resolved(withResult: HybridTtsSession())
|
|
}
|
|
|
|
/// iOS has no concept of swappable synthesis engines, so this always
|
|
/// resolves to an empty array; the reader UI hides engine selection there.
|
|
func getEngines() throws -> Promise<[TtsEngine]> {
|
|
return Promise.resolved(withResult: [])
|
|
}
|
|
|
|
/// iOS ignores `engineName` and lists the system's speech-synthesis voices.
|
|
func getVoices(engineName: String?) throws -> Promise<[TtsVoice]> {
|
|
let voices = AVSpeechSynthesisVoice.speechVoices()
|
|
.map { voice in
|
|
TtsVoice(
|
|
identifier: voice.identifier,
|
|
name: voice.name,
|
|
language: voice.language
|
|
)
|
|
}
|
|
.sorted { $0.name < $1.name }
|
|
return Promise.resolved(withResult: voices)
|
|
}
|
|
}
|