You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-28Lines changed: 28 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,44 +16,36 @@ Palabra has three separate streaming APIs, and the client mirrors that at the to
16
16
|[**Realtime Speech-to-Text API**](#speech-to-text-api)|`palabra.stt(...)`| transcription API: stream audio in, incremental text (and optional translations) out |
17
17
|[**Realtime TTS API**](#realtime-tts-api)|`palabra.tts(...)`| speech synthesis API: stream text in (e.g. from an LLM), audio out |
18
18
19
-
Authentication, connection options, [errors](#errors) and [reconnection](#reconnection) are shared between the two.
19
+
Authentication, regions, [errors](#errors) and [reconnection](#reconnection) are shared by all three.
20
20
21
21
## Authentication
22
22
23
-
Credentials come from the constructor or from the environment:
23
+
Everything is driven by two values — an **API Key** and a **region**; all endpoints are derived from them automatically. Create your API Key on the [Palabra API Keys page](https://platform.palabra.dev/api-keys) and set it via the environment or the constructor:
24
24
25
25
```bash
26
-
exportPALABRA_CLIENT_ID=...
27
-
exportPALABRA_CLIENT_SECRET=...
26
+
exportPALABRA_API_KEY=...
27
+
exportPALABRA_REGION=eu # optional, defaults to "eu"
28
28
```
29
29
30
30
```python
31
31
from palabra_ai import Palabra
32
32
33
-
palabra = Palabra() # reads the env vars
34
-
palabra = Palabra(client_id="...", client_secret="...") # or explicit
33
+
palabra = Palabra() # reads the env vars
34
+
palabra = Palabra(api_key="...", region="eu") # or explicit
35
35
```
36
36
37
-
Credentials are only used for the REST API (session creation/deletion). They are **not required** for the direct-connection mode below.
37
+
The API Key authorizes the WebSocket connection directly: a streaming session is created server-side when you connect and cleaned up when the connection ends — there is nothing to manage.
38
38
39
-
## Connection options
39
+
## Regions
40
40
41
-
Both `translation()` and `tts()` accept the same three connection modes:
41
+
Availability per region (more regions and endpoints are being added over time):
42
42
43
-
1.**Default** — a session is created via REST on `async with` and deleted on exit. Nothing to manage.
44
-
2.**`session=`** — manually create `Session` with `await palabra.create_session()`; its lifecycle is yours (the client won't delete it).
45
-
3.**`ws_url=` + `token=`** — debug option: connect directly with a direct `ws_url` and already issued `publisher` token. Here is an example:
43
+
| Region | Speech-to-Speech Translation | Speech-to-Text | TTS |
palabra = Palabra() # credentials not required in this mode
49
-
asyncwith palabra.translation(
50
-
source="en",
51
-
targets=["es"],
52
-
ws_url=ws_url,
53
-
token=publisher_token
54
-
) as session:
55
-
...
56
-
```
48
+
Opening a stream for a product that is not available in the configured region raises `ValueError` with the list of regions where it is.
57
49
58
50
---
59
51
@@ -99,7 +91,7 @@ async def main():
99
91
asyncio.run(main())
100
92
```
101
93
102
-
`async with palabra.translation(...)` does everything for you: creates a session via REST, connects the WebSocket, sends translation task, waits until the pipeline actually confirms the task, and cleans up on exit.
94
+
`async with palabra.translation(...)` does everything for you: connects the WebSocket (your API Key authorizes it; a streaming session is created server-side automatically), sends the translation task, waits until the pipeline actually confirms it, and cleans up on exit.
103
95
104
96
Two rules for the input stream:
105
97
@@ -291,7 +283,7 @@ async with palabra.tts(language="en", voice_id="default_low") as tts:
291
283
292
284
All `palabra.tts(...)` options (languages, voices, `speed`, output formats, sample rates), rate limits, and constraints are described in the [Realtime TTS API docs](https://docs.palabra.ai/docs/streaming_api/realtime_tts). Per-message voice overrides can be passed as keyword arguments of `send_text()`/`synthesize()`.
293
285
294
-
[Connection options](#connection-options) are the same as in `translation()`, including `ws_url=`/`token=`. Like the ASR endpoint, the TTS endpoint is a fixed address (`wss://stream.palabra.ai/tts-api/v1/text-to-speech/stream`), not taken from the session response.
286
+
TTS is currently available in the `eu` and `us`[regions](#regions).
-`SessionError` — REST/WebSocket connection problems (including a crashed receive loop — the original exception is attached as `__cause__`).
296
+
-`AuthError` — missing/invalid API Key.
297
+
-`SessionError` — WebSocket connection problems (including a crashed receive loop — the original exception is attached as `__cause__`).
306
298
-`NotReadyError` — the pipeline didn't confirm `set_task` in time (translation only).
307
299
-`TaskError` — the server rejected `set_task` (raised immediately on `async with`, with the server's `code`/`desc`), or raised by `session.raise_on_error(event)` for server `error` messages; by default in-stream errors are delivered as `ServerError` events so a long-running stream survives recoverable errors.
308
-
309
-
REST session creation retries transient failures (network errors, 5xx) a few times with backoff; 4xx fails immediately.
300
+
-`ValueError` — the requested product is not available in the configured [region](#regions), or an unknown region was set.
0 commit comments