A CLI that provides tts using OpenAI
Project description
openai-tts-tool
A command-line interface for OpenAI Text-to-Speech API.
Features
- Convert text to natural-sounding speech
- Six high-quality voices with different characteristics
- Two TTS models (tts-1 and tts-1-hd) for speed vs quality
- Multiple audio formats: mp3, opus, aac, flac
- Stream to speakers or save to files
- Adjustable speech speed (0.25 to 4.0)
- Multi-level verbosity logging
- Shell completion support
Installation
# Prerequisites
# - Python 3.14+
# - uv package manager
# Clone and install globally
git clone https://github.com/dnvriend/openai-tts-tool.git
cd openai-tts-tool
uv tool install .
# Verify installation
openai-tts-tool --version
Configuration
Set the OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"
# Add to shell profile for persistence
echo 'export OPENAI_API_KEY="your-api-key-here"' >> ~/.bashrc # or ~/.zshrc
source ~/.bashrc # or ~/.zshrc
Usage
# Basic synthesis (stream to speakers)
openai-tts-tool synthesize "Hello, world!"
# Save to file with specific voice
openai-tts-tool synthesize "Hello, world!" --voice nova --output hello.mp3
# High-quality synthesis with custom settings
openai-tts-tool synthesize "Welcome" \
--voice alloy \
--model tts-1-hd \
--output welcome.mp3 \
--format mp3 \
--speed 1.2
# Read from stdin
echo "Hello from stdin" | openai-tts-tool synthesize --stdin --output hello.mp3
# List available voices and models
openai-tts-tool list-voices
openai-tts-tool list-models
# Multi-level verbosity for debugging
openai-tts-tool -v synthesize "Test" # INFO level
openai-tts-tool -vv synthesize "Test" # DEBUG level
openai-tts-tool -vvv synthesize "Test" # TRACE with library logs
Options
Synthesize Command
| Option | Short | Description |
|---|---|---|
--voice |
-v |
Voice to use (alloy, echo, fable, onyx, nova, shimmer) |
--model |
-m |
TTS model (tts-1, tts-1-hd) |
--output |
-o |
Output file path (default: stream to speakers) |
--format |
-f |
Audio format (mp3, opus, aac, flac) |
--speed |
-s |
Speech speed (0.25 to 4.0) |
--stdin |
Read text from stdin |
Global Options
| Option | Short | Description |
|---|---|---|
--verbose |
-v |
Verbose output: -v (INFO), -vv (DEBUG), -vvv (TRACE with library logs) |
--version |
Show version information | |
--help |
-h |
Show help message |
Voices and Models
Voices
| Voice | Description |
|---|---|
| alloy | Balanced, natural voice (default) |
| echo | Deeper, authoritative voice |
| fable | Warm, engaging storyteller |
| onyx | Deep, confident voice |
| nova | Clear, professional voice |
| shimmer | Softer, expressive voice |
Models
| Model | Quality | Speed | Use Case |
|---|---|---|---|
| tts-1 | Standard | Fast | Real-time applications |
| tts-1-hd | High | Slower | High-quality audio production |
Audio Formats
| Format | Quality | Use Case |
|---|---|---|
| mp3 | Good | Maximum compatibility |
| opus | Excellent | Streaming, low bandwidth |
| aac | Very Good | Apple devices |
| flac | Lossless | High-fidelity production |
Library Usage
from openai_tts_tool import TTSClient
client = TTSClient(api_key="your-key")
# Stream to speakers
client.synthesize("Hello, world!", voice="alloy")
# Save to file
client.synthesize(
"Hello, world!",
voice="nova",
model="tts-1-hd",
output="hello.mp3",
speed=1.2
)
Development
make install # Install dependencies
make format # Format code with ruff
make lint # Run linting with ruff
make typecheck # Run type checking with mypy
make test # Run tests with pytest
make security # Run all security checks
make check # Run all checks (lint, typecheck, test, security)
make pipeline # Run full pipeline
make build # Build package
make run ARGS="..." # Run openai-tts-tool locally
License
MIT License - see the LICENSE file for details.
Author
Dennis Vriend - GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openai_tts_tool-0.1.0.tar.gz.
File metadata
- Download URL: openai_tts_tool-0.1.0.tar.gz
- Upload date:
- Size: 70.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deb8b76bbd6e2977cc3bfcaedbe67960812f5b8464053de9f8360373d0fc33a6
|
|
| MD5 |
39ef4b4c5065186bcae56aca515d6d44
|
|
| BLAKE2b-256 |
0dd56887a09504af658391c363d81d9bcf72fd5a98bfd71414c58d24a7ced7f2
|
Provenance
The following attestation bundles were made for openai_tts_tool-0.1.0.tar.gz:
Publisher:
workflow.yaml on dnvriend/openai-tts-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openai_tts_tool-0.1.0.tar.gz -
Subject digest:
deb8b76bbd6e2977cc3bfcaedbe67960812f5b8464053de9f8360373d0fc33a6 - Sigstore transparency entry: 742667391
- Sigstore integration time:
-
Permalink:
dnvriend/openai-tts-tool@42ac1ffb586483b153d65eb9748100ad72ebdd70 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dnvriend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@42ac1ffb586483b153d65eb9748100ad72ebdd70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openai_tts_tool-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openai_tts_tool-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
175cec4289ddb3ec57ca98464db0ec893936b523d1252d5c3b95976e8e1e35cd
|
|
| MD5 |
6384eef8d39a88cc128045caa410cfb6
|
|
| BLAKE2b-256 |
8ffab5dc45c8ffea3be528ab8cda214d8209ce1b0725c33ff70954b95522d73d
|
Provenance
The following attestation bundles were made for openai_tts_tool-0.1.0-py3-none-any.whl:
Publisher:
workflow.yaml on dnvriend/openai-tts-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openai_tts_tool-0.1.0-py3-none-any.whl -
Subject digest:
175cec4289ddb3ec57ca98464db0ec893936b523d1252d5c3b95976e8e1e35cd - Sigstore transparency entry: 742667393
- Sigstore integration time:
-
Permalink:
dnvriend/openai-tts-tool@42ac1ffb586483b153d65eb9748100ad72ebdd70 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dnvriend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@42ac1ffb586483b153d65eb9748100ad72ebdd70 -
Trigger Event:
push
-
Statement type: