# Speech Synthesis On Raspberry Pi with KittenTTS

## Overview

https://www.youtube.com/watch?v=GFV4oYIfGBw

With the brand new lightweight [KittenTTS](https://github.com/KittenML/KittenTTS) text-to-speech (TTS) model, it's possible to synthesize text into speech on lower end CPU only hardware like the Raspberry Pi 5. This means you can add some decent sounding English speech to your project without having to deal with network connections, API keys, pay-per-use pricing models, or relying on cloud providers using power hungry GPUs.

This project illustrates how to get started with KittenTTS by making a basic app to read aloud weather forecasts which are pulled from the US National Weather Service API. Once you learn the basics, you can apply them to add speech output to whatever great project you've got in the works.

We've tested KittenTTS successfully on the Raspberry Pi 4 and Pi 5. As expected, the Pi 5 is able to generate audio faster than the Pi 4.

## Parts

Aside from the Pi 4 or 5, this project uses the Adafruit Voice Bonnet, and either 3.5mm powered speakers, or small JST connector speakers.

### USB Powered Speakers

[USB Powered Speakers](https://www.adafruit.com/product/1363)
Add some extra boom to your audio project with these powered loudspeakers. We sampled half a dozen different models to find ones with a good frequency response, so you'll get quality audio output for music playback. Simply connect the standard 3.5mm stereo plug into your Raspberry Pi model...

In Stock
[Buy Now](https://www.adafruit.com/product/1363)
[Related Guides to the Product](https://learn.adafruit.com/products/1363/guides)
![Two square-ish USB Powered Speakers](https://cdn-shop.adafruit.com/640x480/1363-07.jpg)

### Mono Enclosed Speaker - 3W 4 Ohm

[Mono Enclosed Speaker - 3W 4 Ohm](https://www.adafruit.com/product/3351)
Listen up! This 2.8" x 1.2" speaker&nbsp;is&nbsp;a&nbsp;great addition to any audio project where you need 4 ohm impedance and 3W or less of power. We particularly like this&nbsp;speaker&nbsp;as it is&nbsp;small and enclosed for good audio volume and quality. It has a handy JST 2PH...

In Stock
[Buy Now](https://www.adafruit.com/product/3351)
[Related Guides to the Product](https://learn.adafruit.com/products/3351/guides)
![Enclosed Speaker with JST cable](https://cdn-shop.adafruit.com/640x480/3351-01.jpg)

### Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C

[Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C](https://www.adafruit.com/product/5814)
The official Raspberry Pi PD USB-C power supply is here! Superfast with just the right amount of cable length to get your Pi 5 projects up and running! With true Power Delivery support, this supply can easily supply 5 A of current!

Comes in gothy Adafruit Black! Great for use with Pi 4...

In Stock
[Buy Now](https://www.adafruit.com/product/5814)
[Related Guides to the Product](https://learn.adafruit.com/products/5814/guides)
![Angled shot of black, square-shaped power supply block with a coiled black cable.](https://cdn-shop.adafruit.com/640x480/5814-02.jpg)

### Raspberry Pi 5 - 8 GB RAM

[Raspberry Pi 5 - 8 GB RAM](https://www.adafruit.com/product/5813)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing&nbsp;_better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_&nbsp;processor, USB 3.0 ports, and an updated Gigabit Ethernet chip...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5813)
[Related Guides to the Product](https://learn.adafruit.com/products/5813/guides)
![Angled shot of green Raspberry Pi microcontroller.](https://cdn-shop.adafruit.com/640x480/5813-01.jpg)

### Raspberry Pi 4 Model B - 8 GB RAM

[Raspberry Pi 4 Model B - 8 GB RAM](https://www.adafruit.com/product/4564)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4 better than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

In Stock
[Buy Now](https://www.adafruit.com/product/4564)
[Related Guides to the Product](https://learn.adafruit.com/products/4564/guides)
![Angled shot of Raspberry Pi 4](https://cdn-shop.adafruit.com/640x480/4564-00.jpg)

# Speech Synthesis On Raspberry Pi with KittenTTS

## Voice Bonnet Setup

## Raspberry Pi OS Setup

First get the latest release of Raspberry Pi OS installed on your Pi and update all of the built-in software with apt. If you are comfortable with the Raspberry Pi imaging and setup process, you can follow the steps listed [here under the quick start prerequisites](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi#prerequisite-pi-setup-3106227). If you'd like more details, a more [thorough guide page can be found here.](https://learn.adafruit.com/adafruit-voice-bonnet/raspberry-pi-setup)

## Blinka Setup

1. Install Blinka by following the [automated install](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi#automated-install-3081632) section on [this guide page](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi).

2. Install the proper gpio library based on whether you are using a Raspberry Pi 4, or 5.

Activate the same virtual environment created in step 1 if it is not already active.

## Install Voicecard Software

This process is documented in more depth in the [Voice Bonnet guide](https://learn.adafruit.com/adafruit-voice-bonnet/audio-setup).

Make sure you've got the Voice Bonnet installed, and I2C support installed as well!

When you run

```auto
sudo i2cdetect -y 1
```

you should see an entry under **1A** , indicating the hardware sees the audio card. The number may also appear as UU if you already installed software.

![i2cdetect output showing the bonnet connected at the address 0x1a](https://cdn-learn.adafruit.com/assets/assets/000/138/981/medium800/weather_i2cdetect_output.png?1755006173 )

If you don't see the **1A** address, then you need to troubleshoot I2C and the bonnet connection before moving on. Ensure that I2C is enabled and that the bonnet is seated correctly on the Pi headers.

To enable I2C:

- Run `sudo raspi-config`.
- Select Interface Options and press enter.
- Select I2C and press enter.
- Select Yes and press enter.

![raspi-config main menu with Interface Options selected](https://cdn-learn.adafruit.com/assets/assets/000/138/993/medium640/weather_raspi_config_main.png?1755019314)

![raspi-config Interface Options menu with I2C selected](https://cdn-learn.adafruit.com/assets/assets/000/138/994/medium640/weather_raspi_config_interface_options.png?1755019350)

![raspi-config menu to enable I2C with Yes selected](https://cdn-learn.adafruit.com/assets/assets/000/138/995/medium640/weather_raspi_config_enable_i2c.png?1755019375)

If you see **1A** address in the grid, then install the driver software with these steps:

```auto
git clone https://github.com/HinTak/seeed-voicecard
cd seeed-voicecard
git checkout v6.12
sudo ./install.sh
sudo reboot
```

At the end you should see something like this:

![Terminal output of successful completion of the voicecard install script](https://cdn-learn.adafruit.com/assets/assets/000/138/985/medium800/weather_voicecard_install_output.png?1755006483 )

Reboot the Pi to apply the settings set in the last step.

# Checking for the Card

After the Pi comes back up from the reboot, check for the card by running this command.

```auto
aplay -l
```

![Output of aplay -l command showing the voicecard as one of the connected sound devices.](https://cdn-learn.adafruit.com/assets/assets/000/138/986/medium800/weather_list_cards_output.png?1755006671 )

Take note of what card number the device has. You may need to use the card number to output audio from the device. In the picture above, the voicecard is card number 3, yours may be a different number.

You can use `alsamixer` to adjust the volume, don't forget to select the card with&nbsp; **F6** or **'s'** key.

![alsamixer application showing the choose sound device menu with the bonnet voicecard device highlighted.](https://cdn-learn.adafruit.com/assets/assets/000/138/987/medium800/weather_alsamixer_choose_device.png?1755006925 )

A gain of about **60%** is plenty loud! The slider marked **headphone** on the far left controls the volume of output from the 3.5mm jack on the voice bonnet. The sliders marked **speaker** near the center control volume of output from the JST speaker connections.

![alsamixer application volume setting page with headphone volume set to 60.](https://cdn-learn.adafruit.com/assets/assets/000/138/988/medium800/weather_alsamixer_volume.png?1755007062 )

# Headphone/Speaker Test

Make sure the **Audio On/Off switch is set to ON!**

With either headphones plugged into the headphone jack or speaker(s) attached to the JST speaker port, run

```auto
speaker-test -c2
```

You should hear white noise coming from speakers connected to the voice bonnet 3.5mm jack or JST speaker connection(s). If you do not hear anything, then you need to direct the audio output to the correct sound card by using the `-D` or `--device` argument. This is where you need the sound card number for the voice card that you can find with `aplay -l`. To specify the device use `plughw:#,0` as the argument value, replacing the `#` with your card number. For example when the voicecard is device number 3:

```auto
speaker-test -c2 -D plughw:3,0
```

# Speech Synthesis On Raspberry Pi with KittenTTS

## KittenTTS Setup

Info: The KittenTTS model was first released as a developer preview on 8/4/25, this guide works with version 0.1 or 0.2 of the KittenTTS model.

KittenTTS is distributed as a Python package, which makes installation easy. It's most convenient to install KittenTTS in the same virtual environment that you created and installed Blinka into for the Voice Bonnet setup.

```auto
source env/bin/activate
```

Replace `env/` with the path to and name of your virtual environment if you used a different one.

Next install KittenTTS with pip:

```auto
pip install https://github.com/KittenML/KittenTTS/releases/download/0.1/kittentts-0.1.0-py3-none-any.whl
```

The installation will take several minutes depending on your internet connection, and whether you are using a Pi 4 or Pi 5.

## Test KittenTTS
This basic Python script demonstrates how to generate a .wav audio file from text.

```auto
from kittentts import KittenTTS
m = KittenTTS("KittenML/kitten-tts-nano-0.2")

audio = m.generate("This high quality TTS model works without a GPU", voice='expr-voice-2-f' )

# available_voices : [  'expr-voice-2-m', 'expr-voice-2-f', 'expr-voice-3-m', 'expr-voice-3-f',  'expr-voice-4-m', 'expr-voice-4-f', 'expr-voice-5-m', 'expr-voice-5-f' ]

# Save the audio
import soundfile as sf
sf.write('output.wav', audio, 24000)
```

Save the script into a file and run it while inside of the virtual environment. It will create&nbsp; **output.wav**. The first time that you generate audio it will automatically download the model files. You'll see output like this when that happens.

![Output of kittenTTS model download upon first run.](https://cdn-learn.adafruit.com/assets/assets/000/138/989/medium800/weather_kittentts_model_download.png?1755008903 )

To play the wav file, use the `aplay` program.

```auto
aplay output.wav
```

If you do not hear the sound output from the voice bonnet, then you need to target the correct sound card with the `-D` or `--device` arguments the same way as it was done for the `speaker-test` during the voice bonnet setup. Use `aplay -l` to find the card number and then put it in place of the `#` in `plughw:#,0`. For example with sound card number 3:

```auto
aplay --device plughw:3,0 output.wav
```

# Speech Synthesis On Raspberry Pi with KittenTTS

## Weather Narrator

The weather narrator demo comes in three parts:&nbsp;

### **weather\_narrator.toml**

This file contains the following configuration values that you can change.

- `voice` - Which of the KittenTTS voices to use, there are 8 to choose from. See the `available_voices` list for valid options.
- `location_points` - This is a string containing comma separated National Weather Service X and Y grid points. See the&nbsp;[NWS docs for more info](https://weather-gov.github.io/api/gridpoints) about finding appropriate grid points.
- `forecast_length` - The number of periods that should be read aloud during the forecast returned by the NWS API. Typically this is one period for daytime, and another period for nighttime. Bigger numbers means read more future periods of the forecast.
- `sound_device` - The sound card identifier to play audio from i.e. `plughw:3,0`. This is only needed if sound doesn't play out of the voice bonnet by default on your device. See [Voice Bonnet Setup](https://learn.adafruit.com/speech-synthesis-on-raspberry-pi-w-kittentts/voice-bonnet-setup) for information about this value.

### **generate\_forecast.py**

[This **generate\_forecast.py** script](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_KittenTTS/generate_forecast.py) fetches weather from the NWS API and uses KittenTTS to synthesize the current temperature and forecast into **.wav** files. It creates one file for each period up to the `forcast_length` specified in the config file.&nbsp; If you want to keep using this project and get updated weather information all the time, you could setup a [cron job](https://en.wikipedia.org/wiki/Cron) to run this script a few times a day based on your schedule.

### **code.py**

[This **code.py** script](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_KittenTTS/code.py) uses debouncer to poll the IO pin for the button on the voice bonnet. When the button is pressed, a **.wav** sound file is generated with the current date and time, then it and all of the previously generated weather forecast files are played one after another.&nbsp;

## Run The Project

To use this project click the **Download Project Bundle** button below, unzip the file, and copy the downloaded files to your Raspberry Pi. The CircuitPython versions and&nbsp; **lib/** folder inside the download can be ignored. Only **code.py** , **generate\_forecast.py** , and **weather\_narrator.toml** are needed.

Activate the virtual environment with Blinka and KittenTTS installed in it. Install the Adafruit Debouncer library with this command:

```auto
pip install adafruit-circuitpython-debouncer
```

Now run the downloaded python scripts with these commands:

```auto
python generate_forecast.py
python code.py
```

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_KittenTTS/code.py

The script will take a moment to initialize and then print a message indicating it's ready for the button to be pressed.

```terminal
$ python code.py 
initializing...
Press button to hear time and weather...
```

Press the button, and wait a few seconds while it generates the date/time file, then it plays all audio files out of the speakers.

https://www.youtube.com/watch?v=GFV4oYIfGBw


## Featured Products

### Adafruit Voice Bonnet for Raspberry Pi -Two Speakers + Two Mics

[Adafruit Voice Bonnet for Raspberry Pi -Two Speakers + Two Mics](https://www.adafruit.com/product/4757)
Your Raspberry Pi computer is like an electronic brain - and with the **Adafruit Voice Bonnet** you can give it a mouth and ears as well! Featuring two microphones and two 1 Watt speaker outputs using a high quality I2S codec, this Pi add-on will work with _any Raspberry Pi..._

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4757)
[Related Guides to the Product](https://learn.adafruit.com/products/4757/guides)
### USB Powered Speakers

[USB Powered Speakers](https://www.adafruit.com/product/1363)
Add some extra boom to your audio project with these powered loudspeakers. We sampled half a dozen different models to find ones with a good frequency response, so you'll get quality audio output for music playback. Simply connect the standard 3.5mm stereo plug into your Raspberry Pi model...

In Stock
[Buy Now](https://www.adafruit.com/product/1363)
[Related Guides to the Product](https://learn.adafruit.com/products/1363/guides)
### Mono Enclosed Speaker - 3W 4 Ohm

[Mono Enclosed Speaker - 3W 4 Ohm](https://www.adafruit.com/product/3351)
Listen up! This 2.8" x 1.2" speaker&nbsp;is&nbsp;a&nbsp;great addition to any audio project where you need 4 ohm impedance and 3W or less of power. We particularly like this&nbsp;speaker&nbsp;as it is&nbsp;small and enclosed for good audio volume and quality. It has a handy JST 2PH...

In Stock
[Buy Now](https://www.adafruit.com/product/3351)
[Related Guides to the Product](https://learn.adafruit.com/products/3351/guides)
### Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C

[Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C](https://www.adafruit.com/product/5814)
The official Raspberry Pi PD USB-C power supply is here! Superfast with just the right amount of cable length to get your Pi 5 projects up and running! With true Power Delivery support, this supply can easily supply 5 A of current!

Comes in gothy Adafruit Black! Great for use with Pi 4...

In Stock
[Buy Now](https://www.adafruit.com/product/5814)
[Related Guides to the Product](https://learn.adafruit.com/products/5814/guides)
### Raspberry Pi 5 - 8 GB RAM

[Raspberry Pi 5 - 8 GB RAM](https://www.adafruit.com/product/5813)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing&nbsp;_better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_&nbsp;processor, USB 3.0 ports, and an updated Gigabit Ethernet chip...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5813)
[Related Guides to the Product](https://learn.adafruit.com/products/5813/guides)
### Raspberry Pi 4 Model B - 8 GB RAM

[Raspberry Pi 4 Model B - 8 GB RAM](https://www.adafruit.com/product/4564)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4 better than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

In Stock
[Buy Now](https://www.adafruit.com/product/4564)
[Related Guides to the Product](https://learn.adafruit.com/products/4564/guides)

## Related Guides

- [Raspberry Pi Care and Troubleshooting](https://learn.adafruit.com/raspberry-pi-care-and-troubleshooting.md)
- [Adafruit 2.7" eInk Display Breakouts and Shields](https://learn.adafruit.com/adafruit-2-7-eink-display-breakouts-and-shields.md)
- [Working with I2C Devices](https://learn.adafruit.com/working-with-i2c-devices.md)
- [PiGlass](https://learn.adafruit.com/piglass-wearable-raspberry-pi-computer.md)
- [LoRa and LoRaWAN Radio for Raspberry Pi](https://learn.adafruit.com/lora-and-lorawan-radio-for-raspberry-pi.md)
- [Gemma-Powered NeoPixel LED Sound Reactive Drums](https://learn.adafruit.com/gemma-powered-neopixel-led-sound-reactive-drums.md)
- [PyPortal Thingiverse Viewer](https://learn.adafruit.com/pyportal-thingiverse-viewer.md)
- [AdaBox 017](https://learn.adafruit.com/adabox017.md)
- [All About Raspberry Pi HQ Camera Lenses](https://learn.adafruit.com/raspberry-pi-hq-camera-lenses.md)
- [Ambient Video Lighting with HyperHDR](https://learn.adafruit.com/ambient-video-lighting-with-hyperhdr.md)
- [Using Dashblock to Create Custom APIs for PyPortal](https://learn.adafruit.com/using-dashblock-to-create-custom-apis-for-pyportal.md)
- [CLUE Vertical Garden Weather Visualizer](https://learn.adafruit.com/clue-vertical-garden-weather-visualizer.md)
- [Bluetooth Restroom Key Proximity Tracker](https://learn.adafruit.com/bluetooth-restroom-key-proximity-tracker.md)
- [Blinking an LED with the Zephyr RTOS](https://learn.adafruit.com/blinking-led-with-zephyr-rtos.md)
- [Using Google Assistant on the BrainCraft HAT or Voice Bonnet](https://learn.adafruit.com/using-google-assistant-on-the-braincraft-hat.md)
- [Instagram Photo Frame](https://learn.adafruit.com/instagram-photo-frame.md)
