pi-xai-tts
v0.0.0
Published
A pi extension to read aloud the last AI assistant output using xAI TTS
Downloads
95
Readme
pi-xai-tts
A pi extension that reads aloud the last AI assistant output using xAI's Text-to-Speech API.
Installation
Install via npm:
$ pi install npm:pi-xai-ttsOr install from git:
$ pi install git:github.com/richardanaya/pi-xai-ttsConfiguration
Create a JSON file at ~/.pi/xai-tts.json with your API key:
{
"xaiApiKey": "your-api-key-here",
"voice": "leo"
}Replace your-api-key-here with your actual xAI API key. You can get one at https://console.x.ai/
Optional Settings
voice: The voice to use for speech synthesis. Options:
leo(default) - Authoritative, strongeve- Energetic, upbeatara- Warm, friendlyrex- Confident, clearsal- Smooth, balanced
language: BCP-47 language code (e.g.,
en,zh,pt-BR). Defaults toen.speed: Playback speed multiplier (e.g.,
0.5for half speed,1.5for 1.5x speed,2.0for double speed). Defaults to1.0(normal speed). Range:0.5to2.0.
Usage
After the AI responds to your message, type /listen to hear the last assistant message read aloud.
To stop playback early, type /listen-stop.
Examples
# Ask pi something
> What is the capital of France?
[pi responds with "The capital of France is Paris..."]
# Listen to the response
/listen
# The response will be read aloud using xAI TTS
# Stop playback early if needed
/listen-stopRequirements
This extension requires FFmpeg to be installed, specifically the ffplay command.
Installing FFmpeg
macOS:
brew install ffmpegUbuntu/Debian:
sudo apt-get install ffmpegFedora:
sudo dnf install ffmpegWindows: Download from https://ffmpeg.org/download.html and add to PATH
API Reference
This extension uses the xAI Text-to-Speech API:
- Endpoint:
POST https://api.x.ai/v1/tts - Documentation: https://docs.x.ai/developers/model-capabilities/audio/text-to-speech
