@soniox/node 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/index.cjs +987 -239
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +951 -176
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +951 -176
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +983 -240
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,4 +20,47 @@ const client = new SonioxNodeClient({
|
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Environment variables
|
|
24
|
+
|
|
25
|
+
`SonioxNodeClient` reads the following environment variables when the
|
|
26
|
+
corresponding constructor option is not provided:
|
|
27
|
+
|
|
28
|
+
| Variable | Maps to option | Notes |
|
|
29
|
+
| --------------------- | ---------------------- | ------------------------------------------------------------ |
|
|
30
|
+
| `SONIOX_API_KEY` | `api_key` | Required if `api_key` is not passed explicitly. |
|
|
31
|
+
| `SONIOX_REGION` | `region` | Only `'eu'` and `'jp'` are defined; US is the default. |
|
|
32
|
+
| `SONIOX_BASE_DOMAIN` | `base_domain` | Overrides `region` and forms the default hosts. |
|
|
33
|
+
| `SONIOX_API_BASE_URL` | `base_url` | Overrides the REST API host (e.g. `https://api.soniox.com`). |
|
|
34
|
+
| `SONIOX_WS_URL` | `realtime.ws_base_url` | Overrides the STT realtime WebSocket URL. |
|
|
35
|
+
| `SONIOX_TTS_API_URL` | `tts_api_url` | Overrides the REST TTS host. |
|
|
36
|
+
| `SONIOX_TTS_WS_URL` | `realtime.tts_ws_url` | Overrides the TTS realtime WebSocket URL. |
|
|
37
|
+
|
|
38
|
+
Resolution precedence for every setting is:
|
|
39
|
+
|
|
40
|
+
1. Explicit option passed to `new SonioxNodeClient({ ... })`.
|
|
41
|
+
2. Environment variable from the table above.
|
|
42
|
+
3. Value derived from `region` / `base_domain`.
|
|
43
|
+
4. Root default (United States).
|
|
44
|
+
|
|
45
|
+
## Error handling
|
|
46
|
+
|
|
47
|
+
REST calls (including REST TTS) throw `SonioxHttpError` on non-2xx
|
|
48
|
+
responses, network failures, and aborted requests.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { SonioxNodeClient, SonioxHttpError } from '@soniox/node';
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const audio = await client.tts.generate({
|
|
55
|
+
text: 'Hello',
|
|
56
|
+
voice: 'Adrian',
|
|
57
|
+
language: 'en',
|
|
58
|
+
});
|
|
59
|
+
} catch (err) {
|
|
60
|
+
if (err instanceof SonioxHttpError) {
|
|
61
|
+
console.error(err.code, err.statusCode, err.bodyText);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
23
66
|
For the full documentation please go to our docs: [Full Node SDK Documentation](https://soniox.com/docs/stt/SDKs/node-SDK)
|