Skip to main content

quick-tts

Convert text to speech using OpenAI's Text-to-Speech API. A simple, effective Python package that works as both a library and command-line tool.

Installation

pip install quick-tts

Usage

As a Library

from quick_tts import text_to_speech

# Basic usage
text_to_speech("Hello, world!", "hello.mp3")

# With custom options
text_to_speech(
    text="Good morning!",
    output_file="morning.wav",
    model="tts-1-hd",
    voice="nova"
)

As a Command-Line Tool

# Basic usage
quick-tts "Hello, world!" -o hello.mp3

# Read from file
quick-tts -f input.txt -o output.mp3

# Custom voice and model
quick-tts "Welcome!" --voice nova --model tts-1-hd -o welcome.mp3

# See all options
quick-tts --help

Configuration

Option 1: .env File (Recommended)

Create a .env file in your project directory:

# .env
OPENAI_API_KEY=sk-your-api-key-here

The package automatically loads .env files - no additional setup required!

Option 2: Environment Variable

export OPENAI_API_KEY=sk-your-api-key-here

Option 3: Direct Parameter

text_to_speech("Hello!", "hello.mp3", api_key="sk-your-api-key")

API Reference

text_to_speech(text, output_file="speech.mp3", model="tts-1-hd", voice="alloy", api_key=None)

Convert text to speech using OpenAI's API.

Parameters:

  • text (str): The text to convert to speech
  • output_file (str|Path): Path to save the audio file (default: "speech.mp3")
  • model (str): OpenAI TTS model ("tts-1" or "tts-1-hd", default: "tts-1-hd")
  • voice (str): Voice to use ("alloy", "echo", "fable", "onyx", "nova", "shimmer", default: "alloy")
  • api_key (str, optional): OpenAI API key (uses OPENAI_API_KEY env var if not provided)

Returns:

  • str: Absolute path to the generated audio file

Supported Voices

  • alloy - Balanced, versatile voice
  • echo - Clear, professional tone
  • fable - Warm, storytelling quality
  • onyx - Deep, authoritative voice
  • nova - Bright, engaging tone
  • shimmer - Soft, pleasant voice

Models

  • tts-1 - Standard quality, faster generation
  • tts-1-hd - High definition quality, more detailed audio

Requirements

  • Python 3.8+
  • OpenAI API key
  • openai>=1.86.0
  • python-dotenv>=1.1.0

License

MIT License - see LICENSE file for details.

Contributing

Issues and pull requests welcome at GitHub.

Metadata

Release files for quick-tts 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quick-tts 0.1.2
File Size Uploaded Provenance
quick_tts-0.1.2.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for quick-tts 0.1.2
File Interpreter ABI Platform
quick_tts-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / quick_tts-0.1.2.tar.gz

Download URL quick_tts-0.1.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
961898ee27bf6144fe4b064bbad8efcdd66a82e8aed6fb45da2a2b4ffd0ee99e
BLAKE2b-256 checksum
How to use checksums
571350b89af75fb7138cbd06ba86dcb3fa5c269f224584c0dec76d48c330083f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / quick_tts-0.1.2-py3-none-any.whl

Download URL quick_tts-0.1.2-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0556c907b7685d2365a51b9dc6e3c905b0e105c015d66506f4f0b54003d5301
BLAKE2b-256 checksum
How to use checksums
fc326b87095cf580b4e0dc3e10f5b6faf7101220d3bfa8ac248377878593fdea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Security for quick-tts 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page