--- description: Overview of text-to-speech in the ABR SDK, covering on-device synthesis, the streaming push model, and PCM output format. --- # Overview The ABR SDK synthesizes speech from text on-device, with no network round-trip. You push UTF-8 text bytes and receive synthesized PCM (uncompressed audio) back through a callback as the model produces it. ::::{lang-set} :::{lang} python The TTS API is provided by the {api}`module.tts` module. The main class you interact with is {api}`Tts`. ::: :::{lang} c A TTS application is an {c:type}`abr_app_t` created from a TTS package with {c:member}`abr_lib.app_create`. Text goes into its input buffer and audio comes out of its output buffer; the {doc}`session helper ` from the tarball's `examples/common` directory wraps that in `abr_session_push` and `abr_session_wait_for_completion`. ::: :::: ## How synthesis works TTS accepts raw UTF-8 text bytes and produces mono PCM audio. You push text in pieces and a callback fires each time the model produces new audio. Output begins arriving before the full text has been consumed: the model streams audio as it synthesizes, sentence by sentence. ::::{lang-set} :::{lang} python ```{example} synthesize.py ``` The {api}`Tts.push` call runs the synthesis event loop until all input has been accepted: it can block while the model's input buffer is full, and the `on_pcm` callback fires during the call as PCM becomes available. The callback passed to the first `push()` of a session is used for the whole session; the `on_pcm` argument on later calls is ignored (passing the same callback each time, as the examples do, is harmless). An optional `output_poll_timeout_ms` argument keeps the call waiting for output until that many milliseconds after `push()` was called. {api}`Tts.wait_for_completion` signals end-of-input, flushes the synthesis pipeline, and blocks until all audio has been delivered through the callback. ::: :::{lang} c ```{example} synthesize.c ``` `abr_session_push` runs the synthesis event loop until all input has been accepted: it blocks while the model's input buffer is full, and `on_pcm` fires during the call as PCM becomes available. `abr_session_wait_for_completion` pushes a flush marker to signal end-of-input and blocks until all audio has been delivered through the callback. Underneath, text goes in with {c:member}`abr_lib.buf_push` and audio comes out with {c:member}`abr_lib.buf_pull`, paced by an event set; `examples/tts.c` in the tarball shows that loop in full. ::: :::: ## Output format The PCM bytes delivered to `on_pcm` are in the same format as the audio the ASR API consumes: | Property | Value | | ----------- | --------------------------- | | Encoding | Signed 16-bit integer (S16) | | Byte order | Little-endian (LE) | | Channels | Mono (1 channel) | | Sample rate | 16,000 Hz | | Container | Raw bytes. No file headers | One second of output is 32,000 bytes (16,000 samples × 2 bytes per sample). Each `on_pcm` call may deliver any number of samples. ## Text normalization The TTS model itself expects clean, speakable text: no numbers written as digits, no acronyms, no accented characters. The backend normalizes pushed text into that form automatically, one sentence at a time, so raw text can be pushed as-is. ::::{lang-set} :::{lang} python ```python tts.push("Dr. Smith owed $42 to the WHO.".encode("utf-8")) # spoken as "doctor Smith owed forty two dollars to the W H O." ``` ::: :::{lang} c ```c const char text[] = "Dr. Smith owed $42 to the WHO."; abr_session_push(&session, (const uint8_t *)text, strlen(text), on_pcm, NULL); // spoken as "doctor Smith owed forty two dollars to the W H O." ``` ::: :::: See {doc}`/sdk/tts/input-format` for what normalization does. ## What you need to use TTS To run TTS you need three things: ::::{lang-set} :::{lang} python - **The SDK Python package** (`pip install abr-sdk`). ::: :::{lang} c - **The SDK C binding**, compiled into your program (see {doc}`/sdk/getting-started/installation`). ::: :::: - **An application package** for your target platform. This archive contains the compiled model, the network weights, and supporting files. You download it from the [ABR developer portal](https://dev.appliedbrainresearch.com) and extract it on the device. See {doc}`/sdk/concepts/application-packages`. - **UTF-8 text.** Numbers, dates, and abbreviations are converted to spoken words by the backend automatically. :::{admonition} Next steps :class: hint - New to the SDK? Start with {doc}`/sdk/getting-started/tts-quickstart`. - {doc}`/sdk/tts/input-format`: the normalization pipeline and SSML markup. - {doc}`/sdk/tts/voices`: the available voices and how to select one. - {doc}`/sdk/tts/examples`: full, runnable examples for file output, speaker playback, and more. :::