> ## Documentation Index
> Fetch the complete documentation index at: https://developers.namuai-lab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Read messages aloud in Hausa

> Turn a list of messages into small audio files, generated once and reused.

8 min

Read messages aloud in Hausa

**You will build:** a script that reads a file of messages and saves each one as a small Opus file, skipping any message already spoken. Run it again after editing the list: only new or changed messages cost anything.

**You will need:** Python 3.9+, `pip install namu-ai` ([Python library](https://developers.namuai-lab.com/sdks/python.md)), and `NAMU_API_KEY` set.

**1. Write the messages**

One message per line, in `messages.txt`:

```text messages.txt theme={null}
Ina kwana? Yau za a yi zafi sosai, don haka ku sha ruwa da yawa.
Damina ta kama. Lokaci ya yi da manoma su fara shuka gero da dawa.
Kar ki manta, gobe da safe ki kawo jaririnki asibiti don allurar rigakafi.
```

**2. Speak each message once**

The file name is a fingerprint of the voice and the text, so the same message is never generated twice:

```python speak_all.py theme={null}
import hashlib
from pathlib import Path

from namu import Namu, NamuError

client = Namu()
out = Path("audio")
out.mkdir(exist_ok=True)
VOICE = "nadia"

for line in Path("messages.txt").read_text(encoding="utf-8").splitlines():
    text = line.strip()
    if not text:
        continue
    name = hashlib.sha256(f"{VOICE}:{text}".encode()).hexdigest()[:16] + ".ogg"
    target = out / name
    if target.exists():
        print("kept   ", name)
        continue
    try:
        target.write_bytes(client.speech(text, voice=VOICE, format="opus"))
        print("spoken ", name, "←", text[:40])
    except NamuError as e:
        print("failed ", e.type, "←", text[:40])
```

**3. Run it**

```bash theme={null}
python speak_all.py
```

Each file is a few dozen kilobytes: light enough to send over WhatsApp or play on 2G.

## Make it yours

* **Zarma:** set `VOICE = "mouhamad"`; he speaks Zarma unless told otherwise.
* **MP3 for old phones:** `format="mp3"` and `.mp3` names.
* **Serve the files** from your own storage or a CDN; never call the API once per listener.

## Next

> [card] [Voice reminders for a health centre](https://developers.namuai-lab.com/tutorials/voice-messages-for-a-clinic.md)
>
> Personal messages from templates

> [card] [Text to speech](https://developers.namuai-lab.com/capabilities/text-to-speech.md)
>
> Every option


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.