API Reference
The Tontaube API provides text-to-speech capabilities via a simple REST interface.
Get Started
- 1 Create an API key in your Dashboard
- 2 Include the key in the
X-API-Keyheader on every request - 3 Make requests to the base URL below
https://api.tontaube.ai/v1 Authentication
All requests require an X-API-Key header with a valid API key. Keys start with ttb_live_.
curl https://api.tontaube.ai/v1/voices \
-H "X-API-Key: ttb_live_..." Voices
Every speech request uses a voice, passed as voice_id. There are two kinds, listed together by GET /voices and told apart by type:
- Tontaube voices (
"type": "library"): ready-made voices available to every account. - Your voices (
"type": "custom"): voices you clone from a recording withPOST /voices. Only your account can see and use them. You can store up to 50; creating them is currently free.
Speech costs the same with either kind. To try a voice without storing it, send a recording as voice_audio_b64 instead (see Generate Speech).
The voice object
| Field | Type | Kind | Description |
|---|---|---|---|
id | string (UUID) | both | Use as voice_id in speech requests |
name | string | both | Display name |
type | string | both | "library" (Tontaube voice) or "custom" (your voice) |
languages | string[] | both | ISO 639-1 codes. Tontaube voices: the languages they are restricted to (empty = not restricted). Your voices: [language], or empty if none was set. |
preview_url | string | null | both | Signed link to a short audio preview, or null if the voice has none. It expires; list or get the voice again for a fresh one. |
gender | string | null | library | Speaker gender |
voice_style | string | null | library | Style the voice is made for, e.g. Narration, Conversation |
language | string | null | custom | Default language set when the voice was created, or null |
duration_seconds | number | custom | Seconds of the recording that were used (at most 60) |
created_at | string (ISO 8601) | custom | Creation time |
model_version | string | custom | Model that encoded the voice |
n_codebooks | integer | custom | Number of codec levels stored |
codec | string | custom | Codec of the voice encoding |
Responses never contain the voice encoding itself.
/voices Returns an array of voice objects: your voices first (newest first), then the Tontaube voices (recommended first).
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | No | library for Tontaube voices only, custom for your voices only. Omit it for both; any other value returns 422. |
curl https://api.tontaube.ai/v1/voices \
-H "X-API-Key: ttb_live_..."
# Only Tontaube voices, or only your own:
curl "https://api.tontaube.ai/v1/voices?type=library" -H "X-API-Key: ttb_live_..."
curl "https://api.tontaube.ai/v1/voices?type=custom" -H "X-API-Key: ttb_live_..." import requests
voices = requests.get(
"https://api.tontaube.ai/v1/voices",
headers={"X-API-Key": "ttb_live_..."},
).json()
for voice in voices:
print(voice["type"], voice["id"], voice["name"], voice["languages"])
# Only your own voices:
mine = requests.get(
"https://api.tontaube.ai/v1/voices",
params={"type": "custom"},
headers={"X-API-Key": "ttb_live_..."},
).json() [
{
"id": "0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12",
"name": "My narrator",
"type": "custom",
"languages": ["en"],
"preview_url": "https://.../preview.m4a?Expires=...&Signature=...",
"language": "en",
"duration_seconds": 24.6,
"created_at": "2026-11-15T10:24:31.512345Z",
"model_version": "TontaubeV1.1",
"n_codebooks": 8,
"codec": "dualcodec_12hz_v1"
},
{
"id": "32b39669-fe31-479c-b3e4-527998b238f7",
"name": "Frederick",
"type": "library",
"languages": ["en"],
"preview_url": "https://.../frederick.m4a",
"gender": "male",
"voice_style": "Narration"
},
...
] /voices/{voice_id} Returns one voice, a Tontaube voice or one of yours. Responds with 404 (voice_not_found) if the ID is neither a Tontaube voice nor a voice in your account.
curl https://api.tontaube.ai/v1/voices/0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12 \
-H "X-API-Key: ttb_live_..." /voices Creates one of your voices: clones a voice from a reference recording and stores it in your account. The request also generates a short preview of the new voice and usually takes several seconds. If any step fails, nothing is created.
Creating a voice is free, but your account needs a positive balance. Each account can create at most 10 voices per hour and 50 per day (see Limits); deleting a voice does not give a creation back.
Reference audio
- Use 10–60 seconds of clean speech from a single speaker, without music, background noise or other voices.
- At least 3 seconds of audio are required; only the first 60 seconds are used.
- Common formats work (WAV, MP3, M4A, OGG/Opus, FLAC, WebM); files can be up to 10 MB.
- The cloned voice copies the recording's tone, pace and room sound, so record in the style you want to hear.
Request Body
multipart/form-data with these fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | 1–100 characters (surrounding whitespace is trimmed), unique within your account |
language | string | No | Default language for speech with this voice and for its preview: en, de, es, fr, it, nl, pt (regional forms like de-DE are accepted). Without it, the preview and speech default to English. |
file | file | Yes | The reference recording, max 10 MB. See Reference audio below. |
Response Body
201 Created with the new voice object ("type": "custom").
Errors
Error bodies have the form shown below: error is a stable code, message is for humans. Malformed requests (for example a missing name or file field) are rejected by request validation with 422 and a message field instead.
| Status | Meaning |
|---|---|
400 / 415 | The file could not be read as audio |
402 | insufficient_balance: your balance is zero; recharge to create voices |
409 | voice_name_taken: you already have a voice with this name |
409 | voice_limit_reached: you already have 50 voices; delete one first |
413 | audio_too_large: the file is larger than 10 MB |
422 | audio_too_short (under 3 s), invalid_audio, invalid_name or unsupported_language |
429 | voice_create_limit_reached (voices created per hour or day; retry after the Retry-After seconds), or a rate or concurrency limit (see Limits) |
502 | voice_encoding_failed, preview_failed or preview_upload_failed: nothing was created, retry later |
503 | voice_service_unavailable or model_version_mismatch (during a model update): voice cloning is temporarily unavailable, retry later |
504 | voice_encoding_timeout: encoding the voice timed out, retry later |
curl -X POST https://api.tontaube.ai/v1/voices \
-H "X-API-Key: ttb_live_..." \
-F "name=My narrator" \
-F "language=en" \
-F "[email protected]" import requests
with open("reference.mp3", "rb") as f:
response = requests.post(
"https://api.tontaube.ai/v1/voices",
headers={"X-API-Key": "ttb_live_..."},
data={"name": "My narrator", "language": "en"},
files={"file": ("reference.mp3", f, "audio/mpeg")},
timeout=180,
)
response.raise_for_status()
voice = response.json()
print(voice["id"], voice["preview_url"])
# Use the stored voice
speech = requests.post(
"https://api.tontaube.ai/v1/speech/generate",
headers={"X-API-Key": "ttb_live_..."},
json={"text": "Hello from my own voice.", "voice_id": voice["id"]},
timeout=600,
)
speech.raise_for_status()
open("speech.opus.m4a", "wb").write(speech.content) {
"id": "0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12",
"name": "My narrator",
"type": "custom",
"languages": ["en"],
"language": "en",
"duration_seconds": 24.6,
"model_version": "TontaubeV1.1",
"n_codebooks": 8,
"codec": "dualcodec_12hz_v1",
"created_at": "2026-11-15T10:24:31.512345Z",
"preview_url": "https://.../preview.m4a?Expires=...&Signature=..."
} {
"detail": {
"error": "voice_name_taken",
"message": "You already have a voice named 'My narrator'."
}
} /voices/{voice_id} Permanently deletes one of your voices and its preview. Returns 204 No Content. Tontaube voices cannot be deleted (403, voice_not_deletable); unknown IDs return 404. Speech requests that use a deleted voice_id then fail with 404.
curl -X DELETE https://api.tontaube.ai/v1/voices/0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12 \
-H "X-API-Key: ttb_live_..." import requests
response = requests.delete(
"https://api.tontaube.ai/v1/voices/0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12",
headers={"X-API-Key": "ttb_live_..."},
)
assert response.status_code == 204 /speech/generate Generate speech audio from text. Deducts balance based on character count.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to synthesize (max 30,000 characters) |
voice_id | string (UUID) | One of two | A voice from GET /voices: a Tontaube voice or one of your voices |
voice_audio_b64 | string | One of two | Instant clone: a base64-encoded reference recording (plain base64 or a data: URL; WAV, MP3, M4A, OGG/Opus, FLAC, …; max 10 MB decoded; only the first 60 s are used). Nothing is stored. To reuse a voice, create it once with POST /voices. |
language | string | No | ISO 639-1 code: en, de, es, fr, it, nl, pt. Applies to your voices and to voice_audio_b64; when omitted, your voice speaks its own language, otherwise English. Tontaube voices always speak their own language. |
format | string | No | Legacy field. Binary responses are always Opus in MP4 (audio/mp4; codecs=opus); any value is accepted and treated as opus. To choose the format of a JSON response (return_context or include_timestamps), use audio_format. |
temperature | number | No | Controls speech variability. Between 0.5 and 2.0; defaults to 1.0. |
controls | object | null | No | Style controls: a map from control name to an integer step, e.g. {"rate": 1, "pause": 3}. See Style Controls. Omit it or send null to let the model choose everything. |
include_timestamps | boolean | No | English only. Also return when each word and character is spoken; the response becomes JSON. See Word Timestamps. |
return_context | boolean | No | Also return the context of the generated speech, to continue it later with prefix; the response becomes JSON with untrimmed 24 kHz WAV/FLAC audio. See Continuing Speech. |
prefix | object | No | Speech the new audio continues: text (the words spoken before, at most 350 characters) and optionally context, slices of earlier contexts and pauses. See Continuing Speech. |
seed | integer | No | 0 to 4294967295. The same seed with the same request repeats the generation. The seed used (random if omitted) is returned in the X-Seed header and, in JSON responses, as seed. On /speech/stream, X-Seed is set only when you send a seed. |
style | string | No | Delivery style: audiobook, conversational or agentic. Without it, Tontaube voices use their own style. |
audio_format | string | No | Format of the audio in a JSON response only (return_context or include_timestamps): opus (Opus in MP4; default with include_timestamps), wav or flac (16-bit PCM). With return_context: wav (default) or flac. |
sample_rate | integer | No | JSON responses with audio_format wav/flac only: 48000 (default with include_timestamps) or 24000. With return_context always 24000. |
Send exactly one of voice_id or voice_audio_b64; requests with none or more than one voice source (counting speaker_id) are rejected with 422. speaker_id is still accepted as a legacy alias of voice_id for Tontaube voices (see Legacy). Only clone voices you have the rights to and the speaker's consent for.
With return_context, prefix, include_timestamps, seed or style, the whole text is generated in one model call, so text is limited to 2,000 characters, and the response carries an X-Request-ID and an X-Seed header. The response is JSON only with return_context or include_timestamps; otherwise it stays binary Opus in MP4.
Style Controls
Each control is a slider with integer steps starting at 0. Set only the controls you care about: any control you leave out is chosen by the model. Step 0 is a real setting, not “unset”.
Control Steps Lowest step Highest step rate 0–4 much slower much faster pause 0–4 fewer, shorter pauses more, longer pauses pitch_range 0–5 flat monotone very expressive pitch_level 0–4 low, deep voice high voice legato 0–2 crisp staccato normal articulation
legato is one-sided: step 2 is the model's normal articulation, and the crisp steps 0 and 1 also shorten pauses somewhat.
Unknown control names, steps outside the range and non-integer values are rejected with a validation error. Style controls are a TontaubeV1.1 feature; where a request is served without control support, they are ignored without an error.
Response
Returns the generated audio as a binary stream with the appropriate content-type (Opus in an MP4 container, audio/mp4; codecs=opus). The charge is refunded if generation fails.
Response Headers
Header Description X-Sample-Rate Sample rate of the generated audio X-Audio-Duration Duration in seconds X-Cost-USD Cost of this request in USD X-Balance-USD Remaining account balance in USD
curl curl -X POST https://api.tontaube.ai/v1/speech/generate \
-H "X-API-Key: ttb_live_..." \
-H "Content-Type: application/json" \
-d '{
"text": "Hello world",
"voice_id": "32b39669-fe31-479c-b3e4-527998b238f7",
"format": "opus",
"controls": {"rate": 1, "pause": 3}
}' \
--output speech.opus.m4a
Errors
Status Meaning 402Insufficient balance (insufficient_balance) 404Unknown voice_id (voice_not_found; also for voices of other accounts and for legacy speaker_ids of voices the API no longer offers) 409voice_model_mismatch: your voice was created for an earlier model release; create it again from its recording. context_model_mismatch: a prefix.context was made by an earlier model release; send prefix.text without context, or generate the earlier speech again 413voice_audio_b64 larger than 10 MB (audio_too_large) 422Invalid request, unsupported language or unreadable reference audio; invalid_context (a context that was changed or not issued by this API), invalid_prefix or prefix_too_long; with include_timestamps also timestamps_unsupported_language (speech not in English) or timestamps_unavailable (timings could not be produced). None of these is charged. 429Rate or concurrency limit reached 502 / 503 / 504Generation failed, the model is temporarily unavailable (503 context_unavailable: contexts are temporarily unavailable) or timed out. Not charged (refunded).
With one of your voices
curl curl -X POST https://api.tontaube.ai/v1/speech/generate \
-H "X-API-Key: ttb_live_..." \
-H "Content-Type: application/json" \
-d '{
"text": "Hello from my own voice.",
"voice_id": "0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12"
}' \
--output speech.opus.m4a
Instant clone (nothing stored)
Python import base64
import requests
with open("reference.mp3", "rb") as f:
reference_b64 = base64.b64encode(f.read()).decode("ascii")
response = requests.post(
"https://api.tontaube.ai/v1/speech/generate",
headers={"X-API-Key": "ttb_live_..."},
json={
"text": "This voice is cloned on the fly and not stored.",
"voice_audio_b64": reference_b64,
"language": "en",
},
timeout=600,
)
response.raise_for_status()
with open("speech.opus.m4a", "wb") as f:
f.write(response.content)
print("Cost:", response.headers["X-Cost-USD"], "USD")
Continuing Speech (contexts)
To regenerate the end of a sentence, or to continue earlier speech seamlessly, keep the context of what was generated and send slices of it as a prefix later. With "return_context": true the response is JSON:
Response {
"audio_b64": "UklGRiQAAQBXQVZFZm10...",
"mime_type": "audio/wav",
"sample_rate": 24000,
"duration": 3.84,
"seed": 1234,
"context": "ttc1.AQEEADAA...",
"n_frames": 48,
"frame_hz": 12.5,
"model_version": "TontaubeV1.1",
"cost_usd": "0.000120",
"balance_usd": "4.991200",
"request_id": "3f0c9a6e2b7d4c1e9f8a5b6c7d8e9f01"
}
- The audio is untrimmed 24 kHz mono, 16-bit (
audio_format wav, the default, or flac: identical samples), exactly n_frames × 1920 samples long. Frame i of the context covers [i × 80 ms, (i + 1) × 80 ms). context is a signed string of the audio's speech codes: keep it with the audio and do not change it. A changed context is rejected with 422 invalid_context. Contexts do not expire, but they are bound to the model release in model_version: after a model update they are refused with 409 context_model_mismatch. prefix.text (1–350 characters) must be the words spoken in the context slices. prefix.context is a list of at most 16 items, each either a slice {"ref": "<context>", "start": 120, "end": 245} (frames start to end, end exclusive, of an earlier context) or a pause {"silence": 6} (1–25 frames of silence). At least one slice is required, and all items together are at most 400 frames (32 s); longer prefixes get 422 prefix_too_long. - The new audio starts right after the prefix and fades in over its first 10 ms. Cut your audio at the matching sample (
frame × 1920 at 24 kHz) and fade its last 10 ms out. - Without
context, the model first speaks prefix.text itself (not returned) and continues from there. A prefix replaces a Tontaube voice's built-in style prefix. - Billing:
text characters. A prefix with context is free; a prefix without context adds its prefix.text characters. Returning a context costs nothing extra. - If contexts are temporarily unavailable, requests that need one get
503 context_unavailable before anything is charged.
Python import base64
import requests
API = "https://api.tontaube.ai/v1/speech/generate"
HEADERS = {"X-API-Key": "ttb_live_..."}
VOICE = "0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12"
# 1. Generate and keep the context (the response is JSON with WAV audio)
first = requests.post(API, headers=HEADERS, timeout=600, json={
"text": "I told her the truth, and she laughed.",
"voice_id": VOICE,
"return_context": True,
"seed": 1234,
})
first.raise_for_status()
first = first.json()
part1 = base64.b64decode(first["audio_b64"]) # 24 kHz, n_frames * 1920 samples
# 2. Replace everything after frame 60 (4.8 s): continue from the first 60 frames
second = requests.post(API, headers=HEADERS, timeout=600, json={
"text": "and she said nothing.",
"voice_id": VOICE,
"prefix": {
"text": "I told her the truth,", # the words spoken in frames 0-60
"context": [{"ref": first["context"], "start": 0, "end": 60}],
},
"return_context": True,
})
second.raise_for_status()
second = second.json()
# Join: part 1 cut at sample 60 * 1920 (fade its last 10 ms out), then part 2's audio.
include_timestamps can be combined with return_context or prefix; the timings then refer to the untrimmed 24 kHz audio.
Word Timestamps
Send "include_timestamps": true to get, with the audio, when each word and each character is spoken — for subtitles, karaoke-style highlighting or lip sync. Timestamps are available for English speech only: a request whose voice speaks another language is rejected with 422 timestamps_unsupported_language before anything is charged (Tontaube voices always speak their own language). They are not available on /speech/stream.
The response is JSON instead of binary audio. The audio is the same as without timestamps (edge silence trimmed, enhanced, 48 kHz), base64-encoded in audio_b64: Opus in MP4 by default, or 16-bit wav/flac with audio_format (resampled to 24 kHz with "sample_rate": 24000). sample_rate and duration describe the returned audio.
Response {
"audio_b64": "AAAAHGZ0eXBpc29t...",
"mime_type": "audio/mp4; codecs=opus",
"sample_rate": 48000,
"duration": 2.18,
"seed": 1830442912,
"cost_usd": "0.000240",
"balance_usd": "4.991200",
"request_id": "3f0c9a6e2b7d4c1e9f8a5b6c7d8e9f01",
"timestamps": {
"text": "Hello, the total is twenty dollars.",
"words": [
{"text": "Hello,", "start": 0.12, "end": 0.48, "char_start": 0, "char_end": 6, "confidence": 0.93},
{"text": "the", "start": 0.56, "end": 0.66, "char_start": 7, "char_end": 10, "confidence": 0.9},
...
{"text": "dollars.", "start": 1.62, "end": 2.02, "char_start": 27, "char_end": 35, "confidence": 0.95}
],
"characters": [
{"char": "H", "index": 0, "start": 0.12, "end": 0.18},
{"char": "e", "index": 1, "start": 0.18, "end": 0.24},
...
]
}
}
- Times are in seconds from the start of the returned audio. Opus in MP4 marks the codec's priming samples in the MP4 edit list; players and decoders that honor it (browsers, ffmpeg) start exactly at time 0 of the timings.
timestamps.text is the text as it was spoken. Numbers, amounts, dates and abbreviations are spelled out ($20 becomes “twenty dollars”), so it can differ from your text. char_start/char_end (end exclusive) of a word and index of a character point into timestamps.text. - A word that could not be aligned has
start and end null and confidence 0; confidence ranges from 0 to 1. - Billing is the same as for a request without timestamps. Uncertain timings (low confidence or
null times) are not refunded; if timings cannot be produced at all, the request fails with 422 timestamps_unavailable and is not charged.
Python import base64
import requests
response = requests.post(
"https://api.tontaube.ai/v1/speech/generate",
headers={"X-API-Key": "ttb_live_..."},
json={
"text": "Hello, the total is $20.",
"voice_id": "0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12",
"include_timestamps": True,
},
timeout=600,
)
response.raise_for_status()
result = response.json()
with open("speech.opus.m4a", "wb") as f: # audio_format "opus" (default): Opus in MP4
f.write(base64.b64decode(result["audio_b64"]))
timestamps = result["timestamps"]
for word in timestamps["words"]:
print(word["text"], word["start"], word["end"]) # seconds; None if not aligned
/speech/stream Streams speech as MP3 (audio/mpeg, chunked transfer) while it is being generated. Playback can start with the first chunk, typically within about 2 seconds.
Request Body
Same body as POST /speech/generate: text, exactly one of voice_id or voice_audio_b64, and optionally language, temperature, controls, style, seed and prefix. text is limited to 6,000 characters (about 8 minutes of audio at normal speech rate), also with style, seed or prefix; longer texts are rejected with 422 before anything is charged, use /speech/generate for them. format is ignored: the stream is always MP3, 24 kHz, 64 kbit/s. A prefix is context only: the stream starts with the new text, and a prefix without context adds its characters to the price, as on /speech/generate. With a seed, the response carries it in the X-Seed header. return_context and include_timestamps are not available on streams (422 unsupported_field).
Response
A chunked audio/mpeg body. Write the chunks to a file, or feed them to a player that accepts MP3 streams (in browsers, Media Source Extensions with audio/mpeg).
Response Headers
| Header | Description |
|---|---|
X-Cost-USD | Amount charged when the stream starts, in USD (part of it is refunded if the stream ends early, see below) |
X-Balance-USD | Remaining account balance in USD after that charge |
X-Request-ID | ID of this request, for support |
X-Sample-Rate | Sample rate of the audio (24000) |
Billing and failures
A single stream runs for at most 10 minutes. The full price (by character count) is charged before generation starts. If generation fails before the first audio byte, you get an HTTP error (502, 503 or 504) and the charge is refunded. Once audio has started, the status is already 200. If the stream then ends early — generation fails, the 10-minute limit is reached, or you close the connection — generation stops and you pay only for the audio that was produced: the characters that can have been spoken in it (at most 25 characters per second of audio); the rest of the charge is refunded to your balance shortly after. A stream cut by a failure or the time limit is closed without the final chunk, so your HTTP client reports an incomplete response. At normal speech rate a 6,000-character text ends well within 10 minutes; very slow settings (the slowest rate) can come close to it. Other errors are the same as for /speech/generate.
curl -N -X POST https://api.tontaube.ai/v1/speech/stream \
-H "X-API-Key: ttb_live_..." \
-H "Content-Type: application/json" \
-d '{
"text": "Streaming starts playing within a couple of seconds.",
"voice_id": "0b7c6f9e-2f4d-4a51-9a39-5d0f1c6e8a12"
}' \
--output speech.mp3 import requests
with requests.post(
"https://api.tontaube.ai/v1/speech/stream",
headers={"X-API-Key": "ttb_live_..."},
json={
"text": "Streaming starts playing within a couple of seconds.",
"voice_id": "32b39669-fe31-479c-b3e4-527998b238f7",
},
stream=True,
timeout=(10, 120),
) as response:
response.raise_for_status()
with open("speech.mp3", "wb") as f:
for chunk in response.iter_content(chunk_size=None):
f.write(chunk) # or feed each chunk to an MP3 player Legacy
GET /speech/speakers still lists the Tontaube voices (without type and without your voices), and speaker_id is still accepted in /speech/generate and /speech/stream as an alias of voice_id for those voices. Their IDs are the same. Speaker IDs of the earlier generation of voices, which GET /speech/speakers no longer lists, are not accepted any more: requests with them fail with 404 voice_not_found before anything is charged. Pick a current voice from GET /voices instead. New code should use GET /voices and voice_id. The format field is legacy too: binary responses are always Opus in MP4.
# Still supported (legacy): public speakers and speaker_id
curl https://api.tontaube.ai/v1/speech/speakers \
-H "X-API-Key: ttb_live_..."
curl -X POST https://api.tontaube.ai/v1/speech/generate \
-H "X-API-Key: ttb_live_..." \
-H "Content-Type: application/json" \
-d '{"text": "Hello world", "speaker_id": "32b39669-fe31-479c-b3e4-527998b238f7"}' \
--output speech.opus.m4a pip install tontaube import tontaube
with tontaube.Client(api_key="ttb_live_...") as client:
voice = client.create_voice(name="My voice", audio="my_recording.wav")
response = client.generate_speech(
text="I am here to help you with your project. Tell me what we are building today, and I will get right to work.",
voice_id=voice.id,
style="conversational",
)
with open("speech.m4a", "wb") as f:
f.write(response.content)
print(f"Cost: ${response.cost_usd}, Balance: ${response.balance_usd}")
print("Result saved to speech.m4a")