Skip to main content

OpenTTS

PyPI version PyPI - Python Version

OpenTTS is a simple, unified Python library for text-to-speech conversion. It provides an easy-to-use interface that works with multiple TTS providers, giving you flexibility in choosing the best voice for your needs.


✨ What makes OpenTTS special?

  • 🔄 Multiple Providers: Choose from different TTS services based on your requirements
  • 🎯 Simple API: One consistent interface, no matter which provider you use
  • ⚡ Speed Control: Adjust speech speed for different use cases
  • 🎤 Voice Customization: Add custom prompts to fine-tune voice characteristics
  • 📦 Easy to Extend: Add new providers as they become available
  • 🔧 Familiar Interface: Works just like other popular TTS libraries

🚀 Quick Start

Getting started is super simple:

from opentts import OpenTTS

# Create a client
client = OpenTTS()

# Generate speech
audio_bytes = client.audio.speech.create(
    model="tts-1",
    input="Hello, this is a test of the OpenTTS library!",
    voice="alex"
)

# Save the audio
with open("hello.mp3", "wb") as f:
    f.write(audio_bytes)

That's it! You now have a high-quality MP3 file ready to use.


📦 Installation

Install from PyPI:

pip install opentts-ai

Or for development:

git clone https://github.com/AIMLDev726/opentts-ai.git
cd opentts-ai
pip install -e .

🎙️ Available Providers

SmartVoice Provider

Perfect for general-purpose TTS with great voice quality and fast response times.

  • Best for: Everyday applications, quick prototyping
  • Voices: alex, ben, clara, david, emma, frank, grace, henry, iris, jack, kate, leo, mia, nathan, olivia, peter, quinn, ryan, sophia, thomas
  • Speed Control: Not available
  • Custom Prompts: ✅ Yes, great for customizing voice style

StudioVoice Provider

Professional-grade TTS with advanced features and premium voice quality.

  • Best for: High-quality audio production, professional applications
  • Voices: aria, brooks, charles, dana, elias, felix, gina, harper, ivy, jason, kara, liam, luna, mason, nova, oscar, paige, quincy, riley, sam
  • Speed Control: ✅ Yes, adjust from 0.7x to 1.2x speed
  • Custom Prompts: ✅ Yes, extensive customization options

💡 Usage Examples

Basic Usage

from opentts import OpenTTS

client = OpenTTS()
audio = client.audio.speech.create(
    model="tts-1",
    input="Welcome to our application!",
    voice="alex"
)

Speed Control with StudioVoice

# Speak faster for tutorials or quick announcements
audio = client.audio.speech.create(
    model="tts-1",
    input="Let's speed this up!",
    voice="aria",
    provider="studio",
    speed=1.1  # 10% faster
)

Custom Voice Style with SmartVoice

# Add personality to your voice
audio = client.audio.speech.create(
    model="tts-1",
    input="Welcome to customer service",
    voice="emma",
    provider="smart",
    prompt="Speak in a calm, professional, and reassuring tone. Sound friendly and approachable."
)

Slower Speech for Clarity

# Perfect for educational content or accessibility
audio = client.audio.speech.create(
    model="tts-1",
    input="This is an important announcement",
    voice="brooks",
    provider="studio",
    speed=0.8  # 20% slower for better comprehension
)

📁 Project Structure

opentts/
├── opentts/               # Main package
│   ├── __init__.py
│   ├── client.py          # Main client interface
│   ├── providers/         # Provider implementations
│   │   ├── provider_1/    # SmartVoice provider
│   │   └── provider_2/    # StudioVoice provider
│   └── types/             # Data models
├── examples/              # Usage examples and notebooks
│   ├── examples.py        # Python examples
│   └── Untitled51.ipynb   # Jupyter notebook examples
├── tests/                 # Test files
│   ├── test_tts.py        # TTS functionality tests
│   └── outputaudio/       # Generated audio test outputs
├── pyproject.toml         # Package configuration
└── README.md

🧪 Testing

Run the test suite to make sure everything works:

# Run all tests
python -m pytest tests/

# Run specific test
python tests/test_tts.py

# Try the examples
python examples/examples.py

Note: All generated audio files are automatically saved to tests/outputaudio/ so you can easily review and clean them up.


📚 API Reference

Creating a Client

from opentts import OpenTTS

client = OpenTTS()  # That's all you need!

Speech Generation

audio_bytes = client.audio.speech.create(
    model="tts-1",           # Model name (use "tts-1" for now)
    input="Your text here",  # The text you want to convert
    voice="alex",            # Voice to use
    provider="smart",        # Optional: "smart" or "studio"
    speed=1.0,              # Optional: speech speed (StudioVoice only)
    prompt="Custom style"   # Optional: voice characteristics
)

Parameters:

  • model: Currently only "tts-1" is supported
  • input: The text you want to convert to speech
  • voice: Voice name (see provider sections above)
  • provider: Which TTS service to use ("smart" or "studio")
  • speed: Speech speed multiplier (0.7-1.2 for StudioVoice)
  • prompt: Custom instructions for voice style

🔧 Advanced Usage

Adding New Providers

Want to add support for a new TTS service? Here's how:

  1. Create a new folder: opentts/providers/provider_3/
  2. Add an __init__.py with provider capabilities
  3. Implement the TTS engine in tts/engine.py
  4. Update the client to recognize your new provider

Error Handling

Always wrap your calls in try-catch blocks:

try:
    audio = client.audio.speech.create(
        model="tts-1",
        input="Hello world!",
        voice="alex"
    )
    print("Success!")
except Exception as e:
    print(f"Something went wrong: {e}")

This software comes with a custom license. Please read the LICENSE file carefully before using it in your projects.

Important Disclaimer: This library uses third-party APIs that may change or become unavailable. We recommend having fallback options in production applications.


🤝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch for your changes
  3. Add tests for any new functionality
  4. Make sure existing tests still pass
  5. Submit a pull request

Metadata

Release files for opentts-ai 0.1.1

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

Source distribution (sdist)

Source distribution for opentts-ai 0.1.1
File Size Uploaded Provenance
opentts_ai-0.1.1.tar.gz 18.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for opentts-ai 0.1.1
File Interpreter ABI Platform
opentts_ai-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.4 kB

Release files / opentts_ai-0.1.1.tar.gz

Download URL opentts_ai-0.1.1.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cbfc960f36f52395d3b130c535966fb16c7a7fae6f860ae2949324b0547d51a3
BLAKE2b-256 checksum
How to use checksums
6c032da12d8287d67574c9b5848c536b41da81c2b797644cb1f7c1e39426f802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / opentts_ai-0.1.1-py3-none-any.whl

Download URL opentts_ai-0.1.1-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b3733b7b6695056a9de549d00b9201c3bd57089e1541e112b9f35d05fc5c642
BLAKE2b-256 checksum
How to use checksums
7ed7a06f8a5fa94d29b4f24077e2ce61ba417385728a5f75a9e4be739dbe753b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for opentts-ai 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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