@supertone/supertone 0.1.1 โ 0.1.2
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 +123 -73
- package/custom_test/realtime_tts_player.ts +64 -3
- package/custom_test/test_real_api.ts +1040 -105
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/lib/custom_utils/text_utils.d.ts +8 -1
- package/dist/commonjs/lib/custom_utils/text_utils.d.ts.map +1 -1
- package/dist/commonjs/lib/custom_utils/text_utils.js +108 -7
- package/dist/commonjs/lib/custom_utils/text_utils.js.map +1 -1
- package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.d.ts +92 -1
- package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.d.ts.map +1 -1
- package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.js +48 -3
- package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.js.map +1 -1
- package/dist/commonjs/models/predictttsdurationusingcharacterrequest.d.ts +92 -1
- package/dist/commonjs/models/predictttsdurationusingcharacterrequest.d.ts.map +1 -1
- package/dist/commonjs/models/predictttsdurationusingcharacterrequest.js +46 -3
- package/dist/commonjs/models/predictttsdurationusingcharacterrequest.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/lib/custom_utils/text_utils.d.ts +8 -1
- package/dist/esm/lib/custom_utils/text_utils.d.ts.map +1 -1
- package/dist/esm/lib/custom_utils/text_utils.js +108 -7
- package/dist/esm/lib/custom_utils/text_utils.js.map +1 -1
- package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.d.ts +92 -1
- package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.d.ts.map +1 -1
- package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.js +47 -2
- package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.js.map +1 -1
- package/dist/esm/models/predictttsdurationusingcharacterrequest.d.ts +92 -1
- package/dist/esm/models/predictttsdurationusingcharacterrequest.d.ts.map +1 -1
- package/dist/esm/models/predictttsdurationusingcharacterrequest.js +45 -2
- package/dist/esm/models/predictttsdurationusingcharacterrequest.js.map +1 -1
- package/examples/custom_voices/create_cloned_voice.ts +4 -3
- package/examples/custom_voices/delete_custom_voice.ts +2 -7
- package/examples/custom_voices/edit_custom_voice.ts +2 -6
- package/examples/custom_voices/get_custom_voice.ts +2 -7
- package/examples/custom_voices/list_custom_voices.ts +2 -7
- package/examples/custom_voices/search_custom_voices.ts +2 -6
- package/examples/text_to_speech/create_speech.ts +3 -8
- package/examples/text_to_speech/create_speech_long_text.ts +3 -7
- package/examples/text_to_speech/create_speech_with_phonemes.ts +3 -7
- package/examples/text_to_speech/create_speech_with_voice_settings.ts +3 -8
- package/examples/text_to_speech/predict_duration.ts +3 -7
- package/examples/text_to_speech/stream_speech.ts +3 -7
- package/examples/text_to_speech/stream_speech_long_text.ts +3 -7
- package/examples/text_to_speech/stream_speech_with_phonemes.ts +3 -7
- package/examples/text_to_speech/stream_speech_with_voice_settings.ts +3 -7
- package/examples/usage/get_credit_balance.ts +2 -6
- package/examples/usage/get_usage.ts +2 -6
- package/examples/usage/get_voice_usage.ts +2 -7
- package/examples/voices/get_voice.ts +2 -6
- package/examples/voices/list_voices.ts +2 -6
- package/examples/voices/search_voices.ts +2 -7
- package/jsr.json +1 -1
- package/openapi.json +101 -9
- package/package.json +1 -1
- package/src/lib/config.ts +2 -2
- package/src/lib/custom_utils/text_utils.ts +117 -7
- package/src/models/apiconverttexttospeechusingcharacterrequest.ts +62 -3
- package/src/models/predictttsdurationusingcharacterrequest.ts +64 -3
package/README.md
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
<!-- Start Summary [summary] -->
|
|
6
|
+
## Summary
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
The official TypesSript SDK for [Supertone API](https://www.supertone.ai/en/api)
|
|
10
|
-
|
|
8
|
+
Supertone Public API: Supertone API is a RESTful API for using our state-of-the-art AI voice models.
|
|
11
9
|
<!-- End Summary [summary] -->
|
|
12
10
|
|
|
13
11
|
<!-- Start SDK Installation [installation] -->
|
|
14
|
-
|
|
15
12
|
## SDK Installation
|
|
16
13
|
|
|
17
14
|
The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
|
|
@@ -19,25 +16,25 @@ The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https
|
|
|
19
16
|
### NPM
|
|
20
17
|
|
|
21
18
|
```bash
|
|
22
|
-
npm add
|
|
19
|
+
npm add <UNSET>
|
|
23
20
|
```
|
|
24
21
|
|
|
25
22
|
### PNPM
|
|
26
23
|
|
|
27
24
|
```bash
|
|
28
|
-
pnpm add
|
|
25
|
+
pnpm add <UNSET>
|
|
29
26
|
```
|
|
30
27
|
|
|
31
28
|
### Bun
|
|
32
29
|
|
|
33
30
|
```bash
|
|
34
|
-
bun add
|
|
31
|
+
bun add <UNSET>
|
|
35
32
|
```
|
|
36
33
|
|
|
37
34
|
### Yarn
|
|
38
35
|
|
|
39
36
|
```bash
|
|
40
|
-
yarn add
|
|
37
|
+
yarn add <UNSET> zod
|
|
41
38
|
|
|
42
39
|
# Note that Yarn does not install peer dependencies automatically. You will need
|
|
43
40
|
# to install zod as shown above.
|
|
@@ -45,20 +42,16 @@ yarn add @supertone/supertone zod
|
|
|
45
42
|
|
|
46
43
|
> [!NOTE]
|
|
47
44
|
> This package is published with CommonJS and ES Modules (ESM) support.
|
|
48
|
-
|
|
49
45
|
<!-- End SDK Installation [installation] -->
|
|
50
46
|
|
|
51
47
|
<!-- Start Requirements [requirements] -->
|
|
52
|
-
|
|
53
48
|
## Requirements
|
|
54
49
|
|
|
55
50
|
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
56
|
-
|
|
57
51
|
<!-- End Requirements [requirements] -->
|
|
58
52
|
|
|
59
53
|
<!-- Start SDK Example Usage [usage] -->
|
|
60
|
-
|
|
61
|
-
## Speech Generation Example
|
|
54
|
+
## SDK Example Usage
|
|
62
55
|
|
|
63
56
|
### Example
|
|
64
57
|
|
|
@@ -84,11 +77,9 @@ async function run() {
|
|
|
84
77
|
run();
|
|
85
78
|
|
|
86
79
|
```
|
|
87
|
-
|
|
88
80
|
<!-- End SDK Example Usage [usage] -->
|
|
89
81
|
|
|
90
82
|
<!-- Start Authentication [security] -->
|
|
91
|
-
|
|
92
83
|
## Authentication
|
|
93
84
|
|
|
94
85
|
### Per-Client Security Schemes
|
|
@@ -100,7 +91,6 @@ This SDK supports the following security scheme globally:
|
|
|
100
91
|
| `apiKey` | apiKey | API key |
|
|
101
92
|
|
|
102
93
|
To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
|
|
103
|
-
|
|
104
94
|
```typescript
|
|
105
95
|
import { Supertone } from "@supertone/supertone";
|
|
106
96
|
|
|
@@ -123,44 +113,108 @@ async function run() {
|
|
|
123
113
|
run();
|
|
124
114
|
|
|
125
115
|
```
|
|
126
|
-
|
|
127
116
|
<!-- End Authentication [security] -->
|
|
128
117
|
|
|
129
|
-
<!-- Start
|
|
118
|
+
<!-- Start Models [models] -->
|
|
119
|
+
|
|
120
|
+
## Models
|
|
121
|
+
|
|
122
|
+
Supertoneโs Text-to-Speech API provides multiple TTS models, each with different supported languages, available voice settings, and streaming capabilities.
|
|
123
|
+
|
|
124
|
+
### Model Overview
|
|
125
|
+
|
|
126
|
+
| Model Name | Identifier | Streaming Support (`stream_speech`) | Voice Settings Support |
|
|
127
|
+
|--------------------|-------------------|--------------------------------------|----------------------------------------------------------|
|
|
128
|
+
| **SONA Speech 1** | `sona_speech_1` | โ
Supported | Supports **all** Voice Settings |
|
|
129
|
+
| **Supertonic API 1** | `supertonic_api_1` | โ Not supported | Supports **only** the `speed` setting (others are ignored) |
|
|
130
|
+
| **SONA Speech 2** | `sona_speech_2` | โ Not supported | Supports **pitch_shift**, **pitch_variance**, **speed** |
|
|
131
|
+
|
|
132
|
+
> [!NOTE]
|
|
133
|
+
> **Streaming Support**
|
|
134
|
+
>
|
|
135
|
+
> Streaming TTS using the `stream_speech` endpoint is **only available for the `sona_speech_1` model**.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### Supported Languages by Model
|
|
130
140
|
|
|
141
|
+
> [!NOTE]
|
|
142
|
+
> The set of supported input languages varies depending on the TTS model.
|
|
143
|
+
|
|
144
|
+
- **sona_speech_1**
|
|
145
|
+
- `en`, `ko`, `ja`
|
|
146
|
+
|
|
147
|
+
- **supertonic_api_1**
|
|
148
|
+
- `en`, `ko`, `ja`, `es`, `pt`
|
|
149
|
+
|
|
150
|
+
- **sona_speech_2**
|
|
151
|
+
- `en`, `ko`, `ja`, `bg`, `cs`, `da`, `el`, `es`, `et`, `fi`, `hu`, `it`, `nl`, `pl`, `pt`, `ro`,
|
|
152
|
+
`ar`, `de`, `fr`, `hi`, `id`, `ru`, `vi`
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### Voice Settings (Optional)
|
|
157
|
+
|
|
158
|
+
Some TTS models support optional voice settings that allow fine control over output speech characteristics (e.g., speed, pitch, pitch variance).
|
|
159
|
+
|
|
160
|
+
> [!NOTE]
|
|
161
|
+
> The available Voice Settings vary depending on the TTS model.
|
|
162
|
+
|
|
163
|
+
- **sona_speech_1**
|
|
164
|
+
- Supports **all** available Voice Settings.
|
|
165
|
+
|
|
166
|
+
- **supertonic_api_1**
|
|
167
|
+
- Supports **only** the `speed` setting.
|
|
168
|
+
All other settings will be ignored.
|
|
169
|
+
|
|
170
|
+
- **sona_speech_2**
|
|
171
|
+
- Supports the following Voice Settings:
|
|
172
|
+
- `pitch_shift`
|
|
173
|
+
- `pitch_variance`
|
|
174
|
+
- `speed`
|
|
175
|
+
|
|
176
|
+
> All Voice Settings are optional. When omitted, each modelโs default values will be applied.
|
|
177
|
+
|
|
178
|
+
<!-- End Models [models] -->
|
|
179
|
+
|
|
180
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
131
181
|
## Available Resources and Operations
|
|
132
182
|
|
|
183
|
+
<details open>
|
|
184
|
+
<summary>Available methods</summary>
|
|
185
|
+
|
|
133
186
|
### [customVoices](docs/sdks/customvoices/README.md)
|
|
134
187
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
188
|
+
* [createClonedVoice](docs/sdks/customvoices/README.md#createclonedvoice) - Create cloned voice
|
|
189
|
+
* [listCustomVoices](docs/sdks/customvoices/README.md#listcustomvoices) - Gets custom (cloned) voices
|
|
190
|
+
* [searchCustomVoices](docs/sdks/customvoices/README.md#searchcustomvoices) - Search custom (cloned) voices
|
|
191
|
+
* [getCustomVoice](docs/sdks/customvoices/README.md#getcustomvoice) - Get single cloned voice
|
|
192
|
+
* [editCustomVoice](docs/sdks/customvoices/README.md#editcustomvoice) - Update cloned voice (partial update)
|
|
193
|
+
* [deleteCustomVoice](docs/sdks/customvoices/README.md#deletecustomvoice) - Delete cloned voice
|
|
194
|
+
|
|
141
195
|
|
|
142
196
|
### [textToSpeech](docs/sdks/texttospeech/README.md)
|
|
143
197
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
198
|
+
* [createSpeech](docs/sdks/texttospeech/README.md#createspeech) - Convert text to speech
|
|
199
|
+
* [streamSpeech](docs/sdks/texttospeech/README.md#streamspeech) - Convert text to speech with streaming response
|
|
200
|
+
* [predictDuration](docs/sdks/texttospeech/README.md#predictduration) - Predict text-to-speech duration
|
|
147
201
|
|
|
148
202
|
### [usage](docs/sdks/usage/README.md)
|
|
149
203
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
204
|
+
* [getVoiceUsage](docs/sdks/usage/README.md#getvoiceusage) - Retrieve TTS API usage data
|
|
205
|
+
* [getUsage](docs/sdks/usage/README.md#getusage) - Retrieve advanced API usage analytics
|
|
206
|
+
* [getCreditBalance](docs/sdks/usage/README.md#getcreditbalance) - Retrieve credit balance
|
|
153
207
|
|
|
154
208
|
### [voices](docs/sdks/voices/README.md)
|
|
155
209
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
210
|
+
* [listVoices](docs/sdks/voices/README.md#listvoices) - Gets available voices
|
|
211
|
+
* [searchVoices](docs/sdks/voices/README.md#searchvoices) - Search voices.
|
|
212
|
+
* [getVoice](docs/sdks/voices/README.md#getvoice) - Get voice details by ID
|
|
159
213
|
|
|
214
|
+
</details>
|
|
160
215
|
<!-- End Available Resources and Operations [operations] -->
|
|
161
216
|
|
|
162
217
|
<!-- Start Error Handling [errors] -->
|
|
163
|
-
|
|
164
218
|
## Error Handling
|
|
165
219
|
|
|
166
220
|
[`SupertoneError`](./src/models/errors/supertoneerror.ts) is the base class for all HTTP error responses. It has the following properties:
|
|
@@ -174,44 +228,7 @@ run();
|
|
|
174
228
|
| `error.rawResponse` | `Response` | Raw HTTP response |
|
|
175
229
|
| `error.data$` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
|
|
176
230
|
|
|
177
|
-
###
|
|
178
|
-
|
|
179
|
-
**Primary error:**
|
|
180
|
-
|
|
181
|
-
- [`SupertoneError`](./src/models/errors/supertoneerror.ts): The base class for HTTP error responses.
|
|
182
|
-
|
|
183
|
-
<details><summary>Less common errors (16)</summary>
|
|
184
|
-
|
|
185
|
-
<br />
|
|
186
|
-
|
|
187
|
-
**Network errors:**
|
|
188
|
-
|
|
189
|
-
- [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
|
|
190
|
-
- [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
|
|
191
|
-
- [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
|
|
192
|
-
- [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
|
|
193
|
-
- [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
|
|
194
|
-
|
|
195
|
-
**Inherit from [`SupertoneError`](./src/models/errors/supertoneerror.ts)**:
|
|
196
|
-
|
|
197
|
-
- [`UnauthorizedErrorResponse`](./src/models/errors/unauthorizederrorresponse.ts): Unauthorized: Invalid API key. Status code `401`. Applicable to 10 of 15 methods.\*
|
|
198
|
-
- [`InternalServerErrorResponse`](./src/models/errors/internalservererrorresponse.ts): Status code `500`. Applicable to 10 of 15 methods.\*
|
|
199
|
-
- [`NotFoundErrorResponse`](./src/models/errors/notfounderrorresponse.ts): Status code `404`. Applicable to 9 of 15 methods.\*
|
|
200
|
-
- [`BadRequestErrorResponse`](./src/models/errors/badrequesterrorresponse.ts): Status code `400`. Applicable to 5 of 15 methods.\*
|
|
201
|
-
- [`ForbiddenErrorResponse`](./src/models/errors/forbiddenerrorresponse.ts): Status code `403`. Applicable to 4 of 15 methods.\*
|
|
202
|
-
- [`RequestTimeoutErrorResponse`](./src/models/errors/requesttimeouterrorresponse.ts): Status code `408`. Applicable to 4 of 15 methods.\*
|
|
203
|
-
- [`TooManyRequestsErrorResponse`](./src/models/errors/toomanyrequestserrorresponse.ts): Status code `429`. Applicable to 4 of 15 methods.\*
|
|
204
|
-
- [`PaymentRequiredErrorResponse`](./src/models/errors/paymentrequirederrorresponse.ts): Status code `402`. Applicable to 3 of 15 methods.\*
|
|
205
|
-
- [`PayloadTooLargeErrorResponse`](./src/models/errors/payloadtoolargeerrorresponse.ts): Payload Too Large: File size exceeds 3MB limit. Status code `413`. Applicable to 1 of 15 methods.\*
|
|
206
|
-
- [`UnsupportedMediaTypeErrorResponse`](./src/models/errors/unsupportedmediatypeerrorresponse.ts): Unsupported Media Type: Invalid audio file format. Status code `415`. Applicable to 1 of 15 methods.\*
|
|
207
|
-
- [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
|
|
208
|
-
|
|
209
|
-
</details>
|
|
210
|
-
|
|
211
|
-
\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
|
|
212
|
-
|
|
213
|
-
### Error Handling Example
|
|
214
|
-
|
|
231
|
+
### Example
|
|
215
232
|
```typescript
|
|
216
233
|
import { Supertone } from "@supertone/supertone";
|
|
217
234
|
import * as errors from "@supertone/supertone/models/errors";
|
|
@@ -252,6 +269,38 @@ run();
|
|
|
252
269
|
|
|
253
270
|
```
|
|
254
271
|
|
|
272
|
+
### Error Classes
|
|
273
|
+
**Primary error:**
|
|
274
|
+
* [`SupertoneError`](./src/models/errors/supertoneerror.ts): The base class for HTTP error responses.
|
|
275
|
+
|
|
276
|
+
<details><summary>Less common errors (16)</summary>
|
|
277
|
+
|
|
278
|
+
<br />
|
|
279
|
+
|
|
280
|
+
**Network errors:**
|
|
281
|
+
* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
|
|
282
|
+
* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
|
|
283
|
+
* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
|
|
284
|
+
* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
|
|
285
|
+
* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
**Inherit from [`SupertoneError`](./src/models/errors/supertoneerror.ts)**:
|
|
289
|
+
* [`UnauthorizedErrorResponse`](./src/models/errors/unauthorizederrorresponse.ts): Unauthorized: Invalid API key. Status code `401`. Applicable to 10 of 15 methods.*
|
|
290
|
+
* [`InternalServerErrorResponse`](./src/models/errors/internalservererrorresponse.ts): Status code `500`. Applicable to 10 of 15 methods.*
|
|
291
|
+
* [`NotFoundErrorResponse`](./src/models/errors/notfounderrorresponse.ts): Status code `404`. Applicable to 9 of 15 methods.*
|
|
292
|
+
* [`BadRequestErrorResponse`](./src/models/errors/badrequesterrorresponse.ts): Status code `400`. Applicable to 5 of 15 methods.*
|
|
293
|
+
* [`ForbiddenErrorResponse`](./src/models/errors/forbiddenerrorresponse.ts): Status code `403`. Applicable to 4 of 15 methods.*
|
|
294
|
+
* [`RequestTimeoutErrorResponse`](./src/models/errors/requesttimeouterrorresponse.ts): Status code `408`. Applicable to 4 of 15 methods.*
|
|
295
|
+
* [`TooManyRequestsErrorResponse`](./src/models/errors/toomanyrequestserrorresponse.ts): Status code `429`. Applicable to 4 of 15 methods.*
|
|
296
|
+
* [`PaymentRequiredErrorResponse`](./src/models/errors/paymentrequirederrorresponse.ts): Status code `402`. Applicable to 3 of 15 methods.*
|
|
297
|
+
* [`PayloadTooLargeErrorResponse`](./src/models/errors/payloadtoolargeerrorresponse.ts): Payload Too Large: File size exceeds 3MB limit. Status code `413`. Applicable to 1 of 15 methods.*
|
|
298
|
+
* [`UnsupportedMediaTypeErrorResponse`](./src/models/errors/unsupportedmediatypeerrorresponse.ts): Unsupported Media Type: Invalid audio file format. Status code `415`. Applicable to 1 of 15 methods.*
|
|
299
|
+
* [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
|
|
300
|
+
|
|
301
|
+
</details>
|
|
302
|
+
|
|
303
|
+
\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
|
|
255
304
|
<!-- End Error Handling [errors] -->
|
|
256
305
|
|
|
257
306
|
<!-- Start Additional Example Code [examples] -->
|
|
@@ -262,4 +311,5 @@ Additional example code can be found in the [examples](https://github.com/supert
|
|
|
262
311
|
|
|
263
312
|
<!-- End Additional Example Code [examples] -->
|
|
264
313
|
|
|
314
|
+
|
|
265
315
|
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
@@ -275,10 +275,13 @@ class SimpleMpvPlayer {
|
|
|
275
275
|
*/
|
|
276
276
|
async function simpleStreamingTts(
|
|
277
277
|
voiceId: string,
|
|
278
|
-
text: string
|
|
278
|
+
text: string,
|
|
279
|
+
language: models.APIConvertTextToSpeechUsingCharacterRequestLanguage = models
|
|
280
|
+
.APIConvertTextToSpeechUsingCharacterRequestLanguage.Ko
|
|
279
281
|
): Promise<boolean> {
|
|
280
282
|
console.log(`๐ "${text.slice(0, 50)}${text.length > 50 ? "..." : ""}"`);
|
|
281
283
|
console.log(`๐ Text length: ${text.length} characters`);
|
|
284
|
+
console.log(`๐ Language: ${language}`);
|
|
282
285
|
|
|
283
286
|
const player = new SimpleMpvPlayer();
|
|
284
287
|
|
|
@@ -296,7 +299,7 @@ async function simpleStreamingTts(
|
|
|
296
299
|
voiceId: voiceId,
|
|
297
300
|
apiConvertTextToSpeechUsingCharacterRequest: {
|
|
298
301
|
text: text,
|
|
299
|
-
language:
|
|
302
|
+
language: language,
|
|
300
303
|
outputFormat:
|
|
301
304
|
models.APIConvertTextToSpeechUsingCharacterRequestOutputFormat.Wav,
|
|
302
305
|
style: "neutral",
|
|
@@ -384,7 +387,8 @@ async function simpleStreamingTts(
|
|
|
384
387
|
*/
|
|
385
388
|
async function simpleDemo(): Promise<void> {
|
|
386
389
|
const voiceId = "91992bbd4758bdcf9c9b01";
|
|
387
|
-
const scenarios = [
|
|
390
|
+
const scenarios: string[] = [];
|
|
391
|
+
/*[
|
|
388
392
|
"์๋
ํ์ธ์! ์ฌํํ ํ
์คํธ์
๋๋ค.",
|
|
389
393
|
|
|
390
394
|
"์ค์๊ฐ ํ
์คํธ ์์ฑ ๋ณํ ๊ธฐ์ ์ ์ ๋ง ๋๋์ต๋๋ค. ์ด ๊ธฐ์ ์ ํตํด ๊ธด ํ
์คํธ๋ ์ฆ์ ์์ฑ์ผ๋ก ๋ค์ ์ ์๊ฒ ๋์์ต๋๋ค.",
|
|
@@ -399,6 +403,28 @@ async function simpleDemo(): Promise<void> {
|
|
|
399
403
|
|
|
400
404
|
// Scenario 800+ characters (~850 chars)
|
|
401
405
|
"์๋ ํ ์์ ๋ง์์ ์ฒ์ฌ์ ์ธ ์ฌ๋ฅ์ ๊ฐ์ง ์ ์ ๊ฐ๋ฐ์๊ฐ ์ด๊ณ ์์์ต๋๋ค. ๊ทธ์ ์ด๋ฆ์ ๋ฏผ์ค์ด์๊ณ , ์ด๋ฆด ๋๋ถํฐ ์ปดํจํฐ์ ํ๋ก๊ทธ๋๋ฐ์ ๋จ๋ค๋ฅธ ๊ด์ฌ์ ๋ณด์์ต๋๋ค. ๋ํ์์ ์ปดํจํฐ ๊ณผํ์ ์ ๊ณตํ ๋ฏผ์ค์ ์กธ์
ํ ์คํํธ์
์ ์
์ฌํ์ต๋๋ค. ๊ทธ๊ณณ์์ ๊ทธ๋ ์ธ๊ณต์ง๋ฅ๊ณผ ์์ฑ ๊ธฐ์ ์ ๋ํ ๊น์ ์ง์์ ์๊ฒ ๋์์ต๋๋ค. ์ด๋ ๋ , ๋ฏผ์ค์ ์๊ฐ ์ฅ์ ๊ฐ ์๋ ์น๊ตฌ ์์ฐ์ ๋ง๋ฌ์ต๋๋ค. ์์ฐ์ ์ธํฐ๋ท์ ์๋ง์ ์ ๋ณด๋ฅผ ํ
์คํธ๋ก๋ง ์ ํ ์ ์์ด ๋ง์ ๋ถํธํจ์ ๊ฒช๊ณ ์์์ต๋๋ค. ๋น์์ ์์ฑ ํฉ์ฑ ๊ธฐ์ ์ ๋ก๋ด ๊ฐ์ ๋ชฉ์๋ฆฌ๋ฅผ ๋ด๋ฉฐ, ๊ธด ํ
์คํธ๋ฅผ ์ฝ์ด์ฃผ๋ ค๋ฉด ๋ชจ๋ ์ฒ๋ฆฌ๊ฐ ๋๋ ๋๊น์ง ๊ธฐ๋ค๋ ค์ผ ํ์ต๋๋ค. ์ด๋ฅผ ๋ณธ ๋ฏผ์ค์ ๋ ์์ฐ์ค๋ฝ๊ณ ๋น ๋ฅธ ์์ฑ ํฉ์ฑ ๊ธฐ์ ์ ๋ง๋ค๊ธฐ๋ก ๊ฒฐ์ฌํ์ต๋๋ค. ๋ฐค๋ฎ์์ด ์ฐ๊ตฌ์ ๋งค์งํ ๋ฏผ์ค์ ํ์ ์ ์ธ ์์ด๋์ด๋ฅผ ๋ ์ฌ๋ ธ์ต๋๋ค. ๊ธด ํ
์คํธ๋ฅผ ์์ ๋จ์๋ก ๋๋์ด ์ค์๊ฐ์ผ๋ก ์ฒ๋ฆฌํ๊ณ , ์ฒซ ๋ฒ์งธ ๋ถ๋ถ์ด ์์ฑ๋๋ ์ฆ์ ์ฌ์์ ์์ํ๋ ์คํธ๋ฆฌ๋ฐ ๋ฐฉ์์ด์์ต๋๋ค. ์ด ๊ธฐ์ ์ ๊ตฌํํ๊ธฐ ์ํด ๊ทธ๋ ์ต์ ๋ฅ๋ฌ๋ ๋ชจ๋ธ๊ณผ ์ ๊ฒฝ๋ง ์ํคํ
์ฒ๋ฅผ ์ฐ๊ตฌํ์ต๋๋ค. ์๋ง์ ์ํ์ฐฉ์ค๋ฅผ ๊ฑฐ์ณ ๋ง์นจ๋ด ์์ฐ์ค๋ฌ์ด ์์ฑ์ ์ค์๊ฐ์ผ๋ก ์์ฑํ ์ ์๋ ์์คํ
์ ์์ฑํ์ต๋๋ค. ๊ทธ์ ๊ธฐ์ ์ ๋ฌธ์ฅ์ ๋ฌธ๋งฅ๊ณผ ๊ฐ์ ๊น์ง ์ดํดํ์ฌ ์ ์ ํ ์ต์๊ณผ ์๋๋ก ์ฝ์ด์ฃผ์์ต๋๋ค.",
|
|
406
|
+
];*/
|
|
407
|
+
|
|
408
|
+
// Additional test scenarios for word-based and character-based chunking
|
|
409
|
+
const additionalScenarios = [
|
|
410
|
+
{
|
|
411
|
+
// Korean text WITHOUT punctuation to test word-based chunking
|
|
412
|
+
// Text length: ~450 characters (exceeds 300 char limit)
|
|
413
|
+
text: "์ด๊ฒ์ ๊ตฌ๋์ ์์ด ๋งค์ฐ ๊ธด ๋ฌธ์ฅ์ ํ
์คํธํ๋ ๊ฒ์ผ๋ก ์ผ๋ฐฑ ๊ธ์๋ฅผ ์ด๊ณผํ๋ ํ
์คํธ์์ ๋จ์ด ๊ธฐ๋ฐ ๋ถํ ์ด ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ๋์ง ํ์ธํ๊ธฐ ์ํ ๊ฒ์
๋๋ค ์ด๋ฌํ ๊ฒฝ์ฐ SDK๋ ๋ฌธ์ฅ ๊ฒฝ๊ณ ๋์ ๋จ์ด ๊ฒฝ๊ณ๋ฅผ ์ฌ์ฉํ์ฌ ํ
์คํธ๋ฅผ ์ ์ ํ ํฌ๊ธฐ๋ก ๋๋์ด์ผ ํ๋ฉฐ ์ด๋ ์ฌ์ฉ์๊ฐ ์์ฑํ ์ฝํ
์ธ ์์ ํํ ๋ฐ์ํ ์ ์๋ ์ํฉ์
๋๋ค ์๋ฅผ ๋ค์ด ์ฑํ
๋ฉ์์ง๋ ๋น๊ณต์์ ์ธ ํ
์คํธ ์
๋ ฅ์์๋ ์ฌ๋ฐ๋ฅธ ๋ฌธ๋ฒ๊ณผ ๊ตฌ๋์ ์ด ํญ์ ๋ณด์ฅ๋์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค ๋ํ ์ค์๊ฐ ์คํธ๋ฆฌ๋ฐ ํ๊ฒฝ์์๋ ์ฌ์ฉ์๊ฐ ๋น ๋ฅด๊ฒ ์
๋ ฅํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์์ ๊ตฌ๋์ ์ ์๋ตํ๋ ๊ฒฝ์ฐ๊ฐ ๋น๋ฒํ๊ฒ ๋ฐ์ํฉ๋๋ค ์ด๋ฌํ ์ํฉ์์๋ SDK๋ ์์ ์ ์ผ๋ก ํ
์คํธ๋ฅผ ์ฒ๋ฆฌํ๊ณ ์์ฐ์ค๋ฌ์ด ์์ฑ์ ์์ฑํด์ผ ํฉ๋๋ค ๋ฐ๋ผ์ ๋จ์ด ๊ธฐ๋ฐ ๋ถํ ๊ธฐ๋ฅ์ ๋งค์ฐ ์ค์ํ ์ญํ ์ ๋ด๋นํฉ๋๋ค",
|
|
414
|
+
label:
|
|
415
|
+
"Long sentence without punctuation (Word-based chunking, 450+ chars)",
|
|
416
|
+
category: "Word-based Chunking Test",
|
|
417
|
+
language: models.APIConvertTextToSpeechUsingCharacterRequestLanguage.Ko,
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
// Japanese text WITHOUT punctuation marks (ใ๏ผ๏ผetc) to test pure character-based chunking
|
|
421
|
+
// Text length: ~450 characters (exceeds 300 char limit)
|
|
422
|
+
text: "ๆฅๆฌ่ชใฎใใญในใใฏ้ๅธธในใใผในใๅซใพใชใใใ็นๅฅใชๅฆ็ใๅฟ
่ฆใงใใใฎใในใใฏไธ็พๆๅญใ่ถ
ใใ้ทใๆฅๆฌ่ชใใญในใใๆญฃใใๅฆ็ใใใใใจใ็ขบ่ชใใพใ่ช็ถ่จ่ชๅฆ็ๆ่กใฎ็บๅฑใซใใ้ณๅฃฐๅๆใฎๅ่ณชใฏๅคงๅน
ใซๅไธใใพใใ็นใซใใฃใผใใฉใผใใณใฐใๆดป็จใใๆๆฐใฎใใญในใ้ณๅฃฐๅคๆใทในใใ ใฏไบบ้ใฎ็บ่ฉฑใซ้ๅธธใซ่ฟใ่ช็ถใช้ณๅฃฐใ็ๆใงใใพใในใใผในใใชใ่จ่ชใงใฏๆๅญๅไฝใงใฎๅๅฒใๅฟ
่ฆใงใใใใฎSDKใฏใใฎใใใช็ถๆณใ่ชๅ็ใซๆคๅบใใฆ้ฉๅใซๅฆ็ใใพใใใใซใใๆฅๆฌ่ชไธญๅฝ่ช้ๅฝ่ชใชใฉใฎใขใธใข่จ่ชใงใๅ้กใชใ้ทใใใญในใใ้ณๅฃฐใซๅคๆใใใใจใใงใใพใ้ณๅฃฐๅๆๆ่กใฏ่ฆ่ฆ้ๅฎณ่
ใฎใใใฎใขใฏใปใทใใชใใฃใใผใซใใๅฏพ่ฉฑๅAIใขใทในใฟใณใใพใงๅน
ๅบใ็จ้ใงๆดป็จใใใฆใใพใใใใซใชใขใซใฟใคใ ในใใชใผใใณใฐๆ่กใจ็ตใฟๅใใใใใจใงๅพ
ใกๆ้ใๅคงๅน
ใซ็ญ็ธฎใๅชใใใฆใผใถใผไฝ้จใๆไพใใใใจใใงใใพใๆๆฐใฎ้ณๅฃฐๅๆๆ่กใฏๆๆ
ใๆๆใ่ช็ถใซ่กจ็พใงใใใใใซใชใใพใใ",
|
|
423
|
+
label:
|
|
424
|
+
"Japanese text without spaces AND punctuation (Character-based chunking, 450+ chars)",
|
|
425
|
+
category: "Character-based Chunking Test",
|
|
426
|
+
language: models.APIConvertTextToSpeechUsingCharacterRequestLanguage.Ja,
|
|
427
|
+
},
|
|
402
428
|
];
|
|
403
429
|
|
|
404
430
|
for (let i = 0; i < scenarios.length; i++) {
|
|
@@ -429,6 +455,36 @@ async function simpleDemo(): Promise<void> {
|
|
|
429
455
|
}
|
|
430
456
|
}
|
|
431
457
|
|
|
458
|
+
// Run additional scenarios for chunking tests
|
|
459
|
+
console.log("\n" + "=".repeat(60));
|
|
460
|
+
console.log("๐ง Additional Chunking Test Scenarios");
|
|
461
|
+
console.log("=".repeat(60));
|
|
462
|
+
|
|
463
|
+
for (let i = 0; i < additionalScenarios.length; i++) {
|
|
464
|
+
const scenario = additionalScenarios[i];
|
|
465
|
+
console.log(
|
|
466
|
+
`\n๐ฌ Additional Scenario ${i + 1}/${additionalScenarios.length}`
|
|
467
|
+
);
|
|
468
|
+
console.log(`๐ Category: ${scenario.category}`);
|
|
469
|
+
console.log(`๐ ${scenario.label}`);
|
|
470
|
+
console.log("โ".repeat(50));
|
|
471
|
+
|
|
472
|
+
const success = await simpleStreamingTts(
|
|
473
|
+
voiceId,
|
|
474
|
+
scenario.text,
|
|
475
|
+
scenario.language
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
if (!success) {
|
|
479
|
+
console.log(`โ Additional scenario ${i + 1} failed`);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (i < additionalScenarios.length - 1) {
|
|
483
|
+
console.log("\nโณ Waiting...");
|
|
484
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
432
488
|
console.log("\n๐ Demo completed!");
|
|
433
489
|
console.log("\n๐ Tested text length ranges:");
|
|
434
490
|
console.log(" โข Short text: ~100 chars");
|
|
@@ -436,6 +492,11 @@ async function simpleDemo(): Promise<void> {
|
|
|
436
492
|
console.log(" โข Long text: 300~500 chars");
|
|
437
493
|
console.log(" โข Very long text: 500~800 chars");
|
|
438
494
|
console.log(" โข Extra long text: 800+ chars");
|
|
495
|
+
console.log("\n๐ง Chunking strategy tests:");
|
|
496
|
+
console.log(" โข Word-based chunking: Long sentences without punctuation");
|
|
497
|
+
console.log(
|
|
498
|
+
" โข Character-based chunking: Japanese/Chinese text without spaces"
|
|
499
|
+
);
|
|
439
500
|
}
|
|
440
501
|
|
|
441
502
|
/**
|