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(api_key=YOUR_API_KEY)
# Stream audio chunks
for chunk in client.stream("Hello world!", voice="josh"):
# chunk is raw PCM bytes (int16, 48kHz, mono)
print("Received chunk of length:", len(chunk))
Usage
Pre-connect and Save WAV
import time
import wave
from orpheus_tts import OrpheusClient
API_KEY = "YOUR_API_KEY"
VOICE = "josh"
TEXT = "Hello from Orpheus."
OUTPUT = "output.wav"
client = OrpheusClient(api_key=API_KEY)
client.connect(voice=VOICE, websocket_count=1)
time.sleep(1) # Brief pause to ensure connection is stable
chunks = []
start = time.perf_counter()
for i, chunk in enumerate(client.stream(TEXT, voice=VOICE)):
if i == 0:
print(f"TTFA: {(time.perf_counter() - start) * 1000:.1f}ms")
chunks.append(chunk)
client.close()
audio = b"".join(chunks)
with wave.open(OUTPUT, "wb") as wav:
wav.setnchannels(1)
wav.setsampwidth(2)
wav.setframerate(48000)
wav.writeframes(audio)
Available Voices
from orpheus_tts import VOICES
print(VOICES)
Configuration
client = OrpheusClient(
api_key=YOUR_API_KEY,
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="josh",
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(api_key=YOUR_API_KEY)
try:
for chunk in client.stream("Hello!", voice="josh"):
process(chunk)
except AuthenticationError as e:
print(f"Authentication failed: {e}")
except OrpheusError as e:
print(f"TTS error: {e}")
Connect with environment variables
export ORPHEUS_TTS_API_KEY="YOUR_API_KEY"
from orpheus_tts import OrpheusClient
client = OrpheusClient() # Reads ORPHEUS_TTS_API_KEY
client.connect(websocket_count=1)
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.3.tar.gz
(11.2 MB
view details)
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 orpheus_tts-0.1.3.tar.gz.
File metadata
- Download URL: orpheus_tts-0.1.3.tar.gz
- Upload date:
- Size: 11.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
178e42083bfeb34ca44fefe74145aa09cc2dfeb5b582e4df09e2a536d7f49695
|
|
| MD5 |
9af5dd6a61ecc63fcfceaeb8f452e0a9
|
|
| BLAKE2b-256 |
3ff6dc9fa73b7d8cf9e63819f8665889051715393532371f4084b28deaffd89f
|
File details
Details for the file orpheus_tts-0.1.3-py3-none-any.whl.
File metadata
- Download URL: orpheus_tts-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ff6d3c7446a8abed29277b08bd1cd1c7c8d2d282a1ca3ed417203cf97026650
|
|
| MD5 |
377388ee13bd618ddc6a19960f2f9183
|
|
| BLAKE2b-256 |
7426cab0587480e1fcf5994d68f80bbb353e114b448d26f9aec767645ac3c96a
|