# ABR SDK

Python bindings for the Applied Brain Research on-device speech SDK:
low-latency automatic speech recognition (ASR) and text-to-speech (TTS)
that run entirely on the local device, with no network calls at inference
time.

This package does not contain the speech models or the native engine;
it loads an ABR SDK application package that you obtain separately
and drives it through a small, Pythonic API.

Full documentation: <https://docs.appliedbrainresearch.com/sdk>
Customer portal with application packages: <https://dev.appliedbrainresearch.com>

## Installation

Use any of the following to install `abr-sdk` and incorporate it into your
project.

```bash
pip install abr-sdk
uv add abr-sdk
```

The package is dependency-free and supports Python 3.10+. To run it you also
need an ABR SDK application package for your platform and a license, both
provided by Applied Brain Research.

## Quickstart

Activate the library once per device. This is the only step that needs
network access; inference is fully offline:

```bash
abr-sdk activate path/to/library.so --key-file license.key
```

Recognize speech from 16 kHz mono signed-16-bit little-endian PCM. A chunk may
_replace_ trailing text, so apply each one to a running buffer:

```python
from abr_sdk.asr import Asr, AsrChunk

buf = bytearray()

def on_chunk(chunk: AsrChunk) -> None:
    chunk.update(buf)              # apply correction in place
    print(buf.decode("utf-8"))

with Asr("path/to/libasr.so") as asr:
    while (data := audio_source.read(3200)):   # ~100 ms of PCM
        asr.push(data, on_chunk=on_chunk)
    asr.wait_for_completion()                  # flush and wait for final chunks
```

Synthesize speech to 16 kHz mono signed-16-bit little-endian PCM:

```python
from abr_sdk.tts import Tts

with Tts("path/to/libtts.so") as tts:
    tts.push(b"Hello from Applied Brain Research.", on_pcm=audio_sink.write)
    tts.wait_for_completion()
```

See the [full documentation](https://docs.appliedbrainresearch.com/sdk) for
activation options, full end-to-end examples, and the complete API.

## License

Proprietary. Copyright (c) Applied Brain Research.
Use of this package and the ABR SDK libraries it loads is governed by your
agreement with Applied Brain Research.
