A Rust-based command-line tool for converting text to speech using OpenAI's TTS API.
- 🎯 Easy-to-use command-line interface
- 🔊 High-quality text-to-speech conversion using OpenAI's API
- 📝 Supports large text files through automatic chunking
- 🎨 Multiple voice options and audio formats
- 🔄 Interactive mode for selecting voices and formats
- 📁 Organized output with automatic file management
- 🚀 Progress indicators during conversion
cargo install ttsrs
- Rust (latest stable version)
- ffmpeg (for audio file combining)
- OpenAI API key
- Internet connection
ttsrs [OPTIONS] <INPUT_FILE>
Argument | Description | Default |
---|---|---|
--model , -m |
TTS model to use | tts-1-hd |
--voice , -v |
Voice selection | alloy |
--format , -f |
Output audio format | flac |
--apikey , -a |
OpenAI API key | - |
Available voices with their characteristics:
- alloy - A versatile, well-balanced voice
- echo - Clear and professional, ideal for announcements
- fable - Warm and engaging, perfect for storytelling
- onyx - Deep and authoritative
- nova - Young and energetic
- shimmer - Soft and soothing
Supported output formats:
flac
(default) - Lossless audio compressionmp3
- Common compressed audio formatwav
- Uncompressed audiopcm
- Raw audio data
Basic usage:
ttsrs input.txt
Specifying voice and format:
ttsrs --voice nova --format mp3 input.txt
Using API key inline:
ttsrs --apikey sk-... --voice echo --format wav input.txt
OPENAI_API_KEY
: Your OpenAI API keyexport OPENAI_API_KEY='your-api-key-here'
- Text is automatically chunked into segments of 500 tokens or less
- Each chunk is processed separately and then combined
- Temporary files are automatically cleaned up
- Output is saved in a directory named after the input file
MIT License
Based on the unofficial-openai-tts-cli Python project.