Metadata-Version: 2.5
Name: flockspeech
Version: 0.2.3
Summary: Tiny offline text-to-speech (TTS) for Python: two natural English voices, 44 MB each, that run on any CPU with ONNX Runtime. No GPU, no cloud. Goldfinch laughs on cue with [laugh] tags.
Project-URL: Homepage, https://github.com/flockspeech/flockspeech
Project-URL: Documentation, https://github.com/flockspeech/flockspeech#quick-start
Project-URL: Changelog, https://github.com/flockspeech/flockspeech/releases
Project-URL: Source, https://github.com/flockspeech/flockspeech
Project-URL: Issues, https://github.com/flockspeech/flockspeech/issues
Project-URL: Junco model card, https://huggingface.co/flockspeech/junco
Project-URL: Goldfinch model card, https://huggingface.co/flockspeech/goldfinch
Author: Flock Speech
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
License-File: src/flockspeech/models/LICENSE-vocos
Keywords: accessibility,conversational,cpu,edge-ai,goldfinch,junco,laughter,lightweight,neural-tts,nonverbal,offline,on-device,onnx,onnxruntime,raspberry-pi,screen-reader,small-model,speech,speech-generation,speech-synthesis,text-to-speech,tts,voice,voice-assistant
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Adaptive Technologies
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: espeakng-loader>=0.2.4
Requires-Dist: numpy>=1.22
Requires-Dist: onnxruntime>=1.17
Requires-Dist: phonemizer>=3.2
Description-Content-Type: text/markdown

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/flockspeech/flockspeech/main/assets/flock-horizontal-dark.svg">
    <img src="https://raw.githubusercontent.com/flockspeech/flockspeech/main/assets/flock-horizontal.svg" alt="Flock Speech: tiny offline text-to-speech (TTS) for Python" width="440">
  </picture>
</p>

<p align="center">
  <b>Tiny offline text-to-speech (TTS) for Python that runs on your own CPU.</b><br>
  Two natural English voices, 44 MB each. No GPU, no cloud, no PyTorch. Just <code>pip install flockspeech</code>.
</p>

<p align="center">
  <a href="https://pypi.org/project/flockspeech/"><img src="https://img.shields.io/pypi/v/flockspeech?label=PyPI&color=3E4A57" alt="PyPI"></a>
  <img src="https://img.shields.io/badge/runs%20on-CPU%20%C2%B7%20offline-3E4A57" alt="Runs on CPU, offline">
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-3E4A57" alt="License: Apache-2.0"></a>
  <a href="https://huggingface.co/flockspeech/junco"><img src="https://img.shields.io/badge/Hugging%20Face-Junco-3E4A57?logo=huggingface&logoColor=white" alt="Junco on Hugging Face"></a>
  <a href="https://huggingface.co/flockspeech/goldfinch"><img src="https://img.shields.io/badge/Hugging%20Face-Goldfinch-D9A400?logo=huggingface&logoColor=white" alt="Goldfinch on Hugging Face"></a>
</p>

<p align="center">
  <a href="#voices">Voices</a> ·
  <a href="#installation">Installation</a> ·
  <a href="#quick-start">Quick start</a> ·
  <a href="#sound-tags">Sound tags</a> ·
  <a href="#how-it-works">How it works</a> ·
  <a href="#faq">FAQ</a>
</p>

**Flock Speech** (`flockspeech`) is a lightweight, open-source **text-to-speech (TTS)** library for Python. It turns
English text into natural 24 kHz speech **offline, on an ordinary CPU**, on laptops, servers and 64-bit ARM boards. It
ships two small neural TTS voices:

- **Goldfinch**, a conversational voice that says "uh" and "you know", and laughs or breathes on cue with sound tags
  like `[laugh]`.
- **Junco**, a clear, neutral reading voice for assistants, screen readers and narration.

The voices run with ONNX Runtime and numpy, so there is no GPU, no cloud API key and no PyTorch to install. Your text
never leaves your machine.

---

## Highlights

| Feature | Flock Speech |
|---|---|
| **Model size** | **44.2 MB** per voice, **61.3 MB** for both (they share one 27.1 MB vocoder) |
| **Parameters** | 11.4M acoustic model + 13.5M vocoder |
| **Speed** | **8.7× real time on one CPU thread**, 19× on four (Apple M1) |
| **Start-up** | under a second |
| **Memory** | about 215–265 MB peak for one voice |
| **First audio when streaming** | about 0.25 s |
| **Output** | 24 kHz mono |
| **Runtime** | ONNX Runtime + numpy. Works offline; nothing is downloaded at run time |
| **Platforms** | macOS, Linux (x86-64 and ARM64, including a 64-bit Raspberry Pi OS), Windows |
| **License** | Apache-2.0 for code and weights |

---

## Voices

Every Flock Speech voice is named after a songbird.

<table>
  <tr>
    <td align="center" width="120"><img src="https://raw.githubusercontent.com/flockspeech/flockspeech/main/assets/junco.svg" width="88" alt="Junco, the reading text-to-speech voice"></td>
    <td>
      <b>Junco v0.1</b>: a clear, neutral reading voice.<br>
      Best for assistants, screen readers, notifications and narration.<br>
      <code>Junco()</code> · <code>--voice junco</code> (default) · <a href="https://huggingface.co/flockspeech/junco">model card</a><br>
      Listen:
      <a href="https://huggingface.co/flockspeech/junco/resolve/main/samples/greeting.wav">greeting</a> ·
      <a href="https://huggingface.co/flockspeech/junco/resolve/main/samples/assistant.wav">assistant</a> ·
      <a href="https://huggingface.co/flockspeech/junco/resolve/main/samples/story.wav">story</a> ·
      <a href="https://huggingface.co/flockspeech/junco/resolve/main/samples/news.wav">news</a>
    </td>
  </tr>
  <tr>
    <td align="center" width="120"><img src="https://raw.githubusercontent.com/flockspeech/flockspeech/main/assets/goldfinch.svg" width="88" alt="Goldfinch, the conversational text-to-speech voice"></td>
    <td>
      <b>Goldfinch v0.1</b>: a relaxed, conversational voice that says "uh", laughs and breathes.<br>
      Best for chat companions, game characters and spoken dialogue.<br>
      <code>Goldfinch()</code> · <code>--voice goldfinch</code> · <a href="https://huggingface.co/flockspeech/goldfinch">model card</a><br>
      Listen:
      <a href="https://huggingface.co/flockspeech/goldfinch/resolve/main/samples/laugh.wav">laugh</a> ·
      <a href="https://huggingface.co/flockspeech/goldfinch/resolve/main/samples/chat.wav">chat</a> ·
      <a href="https://huggingface.co/flockspeech/goldfinch/resolve/main/samples/plan.wav">plan</a> ·
      <a href="https://huggingface.co/flockspeech/goldfinch/resolve/main/samples/funny.wav">reaction</a>
    </td>
  </tr>
</table>

Both voices speak English (US). Each is one speaker; there is no voice cloning.

---

## Installation

```bash
pip install flockspeech
```

That's all. The voices are bundled in the package, and the phonemiser (espeak-ng) comes as a pip dependency, so
there is nothing else to install. Python 3.10 or newer.

---

## Quick start

### Command line

```bash
flockspeech "Hello! I'm Junco, and I run on your own computer." -o hello.wav --play
flockspeech "Oh my gosh, [laugh] I can't believe you actually did that." --voice goldfinch --play
```

The CLI also reads text from a file (`-f story.txt`) or from standard input (`echo hi | flockspeech -`).

### Python

```python
from flockspeech import Junco, Goldfinch

tts = Junco()                          # loads in under a second
audio = tts("Hello there.")            # float32 numpy array, 24 kHz mono
tts.save("Hello there.", "hello.wav")

# Low latency: audio is produced sentence by sentence
for chunk in tts.stream(long_text):
    play(chunk)

chat = Goldfinch()
chat.save("Yeah, um, we usually eat dinner around six. [laugh] Late, I know.", "chat.wav")
```

You can also pick a voice by name: `flockspeech.load("goldfinch")`.

---

## Sound tags

Goldfinch understands sound tags. Write one in square brackets where the sound should go:

```text
That's hilarious. [laugh] No, really, it is.
[breath] Okay, so here's the plan for tomorrow.
```

| Tag | Also accepted | Sound | Reliability |
|---|---|---|---|
| `[laugh]` | `[laughs]`, `[giggle]`, `[chuckle]` | a short laugh | good |
| `[breath]` | `[inhale]`, `[exhale]` | an audible breath | good |
| `[throat]` | `[clears throat]`, `[cough]` | clearing the throat | fair |
| `[lipsmack]` | `[lip smack]` | a lip smack | fair |
| `[sigh]` | | a sigh | weak |
| `[noise]` | | a short non-speech noise | weak |

`[sigh]` and `[noise]` had few training examples, so they are weaker. Fillers need no tags: write them as words ("uh",
"um", "you know"). Junco ignores tags.

---

## Options

| Python | CLI | Default | Effect |
|---|---|---|---|
| `Junco()`, `Goldfinch()` | `--voice` | junco | which voice speaks |
| `speed` | `--speed` | 1.0 | 1.2 talks 20% faster |
| `steps` | `--steps` | 8 | generation steps; fewer is faster |
| `seed` | `--seed` | 0 | fixes the small random variation in delivery |
| `threads` | `--threads` | up to 4 | CPU threads for ONNX Runtime |
| `coreml` | `--coreml` | off | Apple silicon: run the vocoder with CoreML. Faster on 1 thread, twice the memory |
| | `--play` | off | play the result |
| | `-o` | out.wav | output file (24 kHz, 16-bit WAV) |

---

## How it works

1. **Phonemes.** espeak-ng turns the text into phonemes. Sound tags become extra symbols.
2. **Acoustic model.** A compact neural network turns the phonemes into a mel spectrogram.
3. **Vocoder.** Vocos turns the spectrogram into sound.

Each voice's acoustic model has 11.4M parameters and was trained from scratch on a single T4 GPU in about three hours:
Junco on LJ Speech, Goldfinch on DisfluencySpeech.

---

## FAQ

### Does Flock Speech need a GPU or an internet connection?

No. Both voices run on an ordinary CPU with ONNX Runtime, and the models are bundled in the package. After
`pip install flockspeech`, speech is generated fully offline and your text never leaves your machine.

### How big are the models?

Each voice is 44.2 MB: a 17.1 MB acoustic model plus a 27.1 MB vocoder. The two voices share the vocoder, so both
together take 61.3 MB.

### How do I make the voice laugh, sigh or breathe?

Use Goldfinch and write a sound tag in square brackets where the sound should go:
`Goldfinch()("That's hilarious. [laugh] No, really.")`. See [Sound tags](#sound-tags) for the full list.

### Can I stream the audio for low latency?

Yes. `tts.stream(text)` yields audio sentence by sentence, so playback can start while the rest is still being
generated.

### Which languages and voices are available?

English (US), with two voices: Goldfinch (conversational) and Junco (reading). There is no voice cloning.

### How should I write numbers, dates and abbreviations?

Write them out in words, such as "five dollars" rather than "$5", and "Doctor" rather than "Dr.". Text normalisation is
not built in yet.

### Which platforms does it run on?

macOS, Linux and Windows, on x86-64 and 64-bit ARM, wherever `onnxruntime` and `espeakng-loader` publish wheels. That
includes 64-bit ARM Linux, such as Raspberry Pi OS. Python 3.10 or newer.

### Can I use it in a commercial product?

The code and voice weights are Apache-2.0 and the bundled Vocos vocoder is MIT, so commercial use is allowed. The
phonemiser (phonemizer and espeak-ng) is GPL-3.0 and is installed as a separate dependency; review its terms before
shipping it inside a closed-source product. See [License](#license).

---

## Links

- **PyPI:** https://pypi.org/project/flockspeech/
- **Junco model card:** https://huggingface.co/flockspeech/junco
- **Goldfinch model card:** https://huggingface.co/flockspeech/goldfinch

---

## License

- **Code and voice weights:** Apache-2.0.
- **Vocos vocoder weights:** MIT (Charactr Inc.), bundled.
- **Phonemiser:** phonemizer and espeak-ng (through `espeakng-loader`) are GPL-3.0. They are installed as separate
  dependencies and are not included in this package.

The Flock Speech name and logo are not covered by the Apache License. See [NOTICE](NOTICE) for details.
