Skip to main content

Python SDK for Orpheus TTS - stream high-quality speech

Project description

Orpheus TTS Python SDK

Stream high-quality speech from the Orpheus TTS model.

Installation

pip install orpheus-tts

Quick Start

from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Stream audio chunks
for chunk in client.stream("Hello world!", voice="antoine"):
    # chunk is raw PCM bytes (int16, 48kHz, mono)
    process_audio(chunk)

Usage

Basic Streaming

from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Stream and save to file
with open("output.pcm", "wb") as f:
    for chunk in client.stream("Welcome to Orpheus TTS!", voice="antoine"):
        f.write(chunk)

Save as WAV

import wave
from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Get complete audio
audio_data = client.stream_to_bytes("Hello, this is a test.", voice="antoine")

# Save as WAV file
with wave.open("output.wav", "wb") as wav:
    wav.setnchannels(1)        # mono
    wav.setsampwidth(2)        # 16-bit
    wav.setframerate(48000)    # 48kHz
    wav.writeframes(audio_data)

Async Streaming

import asyncio
from orpheus_tts import OrpheusClient

async def main():
    client = OrpheusClient()
    
    async for chunk in client.stream_async("Async streaming!", voice="antoine"):
        await process_audio_async(chunk)

asyncio.run(main())

Real-time Playback with PyAudio

import pyaudio
from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Initialize PyAudio
p = pyaudio.PyAudio()
stream = p.open(
    format=pyaudio.paInt16,
    channels=1,
    rate=48000,
    output=True
)

# Stream and play
for chunk in client.stream("This plays in real-time!", voice="antoine"):
    stream.write(chunk)

stream.stop_stream()
stream.close()
p.terminate()

Available Voices

from orpheus_tts import VOICES

print(VOICES)

Configuration

client = OrpheusClient(
    max_tokens=3000,        # Maximum tokens to generate
    temperature=1.0,        # Sampling temperature
    repetition_penalty=1.1, # Repetition penalty
)

# Or override per-request
for chunk in client.stream(
    "Custom settings for this request.",
    voice="antoine",
    max_tokens=2000,
    temperature=0.9,
):
    process(chunk)

Audio Format

All audio is returned as raw PCM with the following format:

  • Sample Rate: 48,000 Hz
  • Bit Depth: 16-bit signed integer (int16)
  • Channels: Mono (1 channel)

Error Handling

from orpheus_tts import OrpheusClient, OrpheusError, AuthenticationError

client = OrpheusClient()

try:
    for chunk in client.stream("Hello!", voice="antoine"):
        process(chunk)
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except OrpheusError as e:
    print(f"TTS error: {e}")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orpheus_tts-0.1.2.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orpheus_tts-0.1.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file orpheus_tts-0.1.2.tar.gz.

File metadata

  • Download URL: orpheus_tts-0.1.2.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.3 cpython/3.11.11 HTTPX/0.28.1

File hashes

Hashes for orpheus_tts-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0347063f7edf9c6374796a64e9608a0362a052e9c5beac1fd1f91b70aab060c4
MD5 9facdc1705e6e7a124ebc8190da7a6be
BLAKE2b-256 d507aff6f40e42d0964391bf9d9ac9e4fdc949e186886fdf2eb785bde1d2229d

See more details on using hashes here.

File details

Details for the file orpheus_tts-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: orpheus_tts-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.3 cpython/3.11.11 HTTPX/0.28.1

File hashes

Hashes for orpheus_tts-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c6d7ba985511eb258d068e851d25bf1e6eba8508df394903c4c6415ad52c67a
MD5 9a9a40080b8b6fd5a81daa2594ad29e4
BLAKE2b-256 1cc5a7a3f4f4471ab3bedf329825a44412b4b6cffd6f791cd8dd452b6b70145a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page