Skip to main content

Module speech

Module speech 

Source
Expand description

Screen reader and text-to-speech output. Available as ctx.speech.

The engine tries these outputs in order and uses the first one that works:

  1. prism (feature prism, on by default). It talks to the running screen reader (NVDA, JAWS, VoiceOver, Orca, …) or falls back to the system voice (SAPI / OneCore, AVSpeech, speech-dispatcher, …).
  2. VoiceOver or the system voice (macOS, feature macos). Speaks through VoiceOver announcements when VoiceOver is on, otherwise through AVSpeechSynthesizer.
  3. The console. Everything is printed, so the game always keeps working.

Speech runs on its own thread, so speaking never blocks your game loop.

Speech::voices lists the voices of the system voice output and Speech::set_voice picks one. Screen readers keep the voice the player chose in the screen reader.

Structs§

Speech
Speech and braille output. Reach it through ctx.speech.
Voice
A voice that Speech::set_voice can switch to. Get the list with Speech::voices.