Skip to content

The ai-tts.rs project provides a command-line tool for generating spoken audio from text files using OpenAI's text-to-speech (TTS) API.

License

Notifications You must be signed in to change notification settings

alexjsteffen/ttsrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ttsrs - Text-to-Speech CLI Tool

A Rust-based command-line tool for converting text to speech using OpenAI's TTS API.

Table of Contents

Features

  • 🎯 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

Installation

cargo install ttsrs

Prerequisites

  • Rust (latest stable version)
  • ffmpeg (for audio file combining)
  • OpenAI API key
  • Internet connection

Usage

Command-Line Arguments

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 -

Voice Options

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

Audio Formats

Supported output formats:

  • flac (default) - Lossless audio compression
  • mp3 - Common compressed audio format
  • wav - Uncompressed audio
  • pcm - Raw audio data

Examples

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

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key
    export OPENAI_API_KEY='your-api-key-here'

Technical Details

  • 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

License

MIT License

Acknowledgments

Based on the unofficial-openai-tts-cli Python project.

About

The ai-tts.rs project provides a command-line tool for generating spoken audio from text files using OpenAI's text-to-speech (TTS) API.

Topics

Resources

License

Stars

Watchers

Forks

Languages