@supertone/supertone 0.1.0 โ 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/FUNCTIONS.md +2 -2
- package/README.md +108 -44
- 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.d.ts.map +1 -1
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/lib/config.js.map +1 -1
- 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/commonjs/sdk/texttospeech.d.ts.map +1 -1
- package/dist/commonjs/sdk/texttospeech.js +12 -9
- package/dist/commonjs/sdk/texttospeech.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.d.ts.map +1 -1
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/lib/config.js.map +1 -1
- 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/dist/esm/sdk/texttospeech.d.ts.map +1 -1
- package/dist/esm/sdk/texttospeech.js +12 -9
- package/dist/esm/sdk/texttospeech.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/package.json +2 -2
- package/examples/textToSpeechCreateSpeech.example.ts +2 -2
- 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 +2 -2
- package/openapi.json +101 -9
- package/package.json +26 -10
- package/src/lib/config.ts +3 -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/src/sdk/texttospeech.ts +474 -465
package/FUNCTIONS.md
CHANGED
|
@@ -19,8 +19,8 @@ specific category of applications.
|
|
|
19
19
|
## Example
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import { SupertoneCore } from "supertone/core.js";
|
|
23
|
-
import { textToSpeechCreateSpeech } from "supertone/funcs/textToSpeechCreateSpeech.js";
|
|
22
|
+
import { SupertoneCore } from "@supertone/supertone/core.js";
|
|
23
|
+
import { textToSpeechCreateSpeech } from "@supertone/supertone/funcs/textToSpeechCreateSpeech.js";
|
|
24
24
|
|
|
25
25
|
// Use `SupertoneCore` for best tree-shaking performance.
|
|
26
26
|
// You can create one instance of it to use across an application.
|
package/README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Supertone TypeScript Library
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
<!-- Start Summary [summary] -->
|
|
6
|
-
##
|
|
7
|
-
|
|
8
|
-
The official Python SDK for [Supertone API](https://www.supertone.ai/en/api)
|
|
6
|
+
## Summary
|
|
9
7
|
|
|
8
|
+
Supertone Public API: Supertone API is a RESTful API for using our state-of-the-art AI voice models.
|
|
10
9
|
<!-- End Summary [summary] -->
|
|
11
10
|
|
|
12
11
|
<!-- Start SDK Installation [installation] -->
|
|
@@ -52,12 +51,12 @@ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
|
52
51
|
<!-- End Requirements [requirements] -->
|
|
53
52
|
|
|
54
53
|
<!-- Start SDK Example Usage [usage] -->
|
|
55
|
-
##
|
|
54
|
+
## SDK Example Usage
|
|
56
55
|
|
|
57
56
|
### Example
|
|
58
57
|
|
|
59
58
|
```typescript
|
|
60
|
-
import { Supertone } from "supertone";
|
|
59
|
+
import { Supertone } from "@supertone/supertone";
|
|
61
60
|
|
|
62
61
|
const supertone = new Supertone({
|
|
63
62
|
apiKey: "<YOUR_API_KEY_HERE>",
|
|
@@ -93,7 +92,7 @@ This SDK supports the following security scheme globally:
|
|
|
93
92
|
|
|
94
93
|
To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
|
|
95
94
|
```typescript
|
|
96
|
-
import { Supertone } from "supertone";
|
|
95
|
+
import { Supertone } from "@supertone/supertone";
|
|
97
96
|
|
|
98
97
|
const supertone = new Supertone({
|
|
99
98
|
apiKey: "<YOUR_API_KEY_HERE>",
|
|
@@ -116,9 +115,74 @@ run();
|
|
|
116
115
|
```
|
|
117
116
|
<!-- End Authentication [security] -->
|
|
118
117
|
|
|
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
|
|
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
|
+
|
|
119
180
|
<!-- Start Available Resources and Operations [operations] -->
|
|
120
181
|
## Available Resources and Operations
|
|
121
182
|
|
|
183
|
+
<details open>
|
|
184
|
+
<summary>Available methods</summary>
|
|
185
|
+
|
|
122
186
|
### [customVoices](docs/sdks/customvoices/README.md)
|
|
123
187
|
|
|
124
188
|
* [createClonedVoice](docs/sdks/customvoices/README.md#createclonedvoice) - Create cloned voice
|
|
@@ -147,6 +211,7 @@ run();
|
|
|
147
211
|
* [searchVoices](docs/sdks/voices/README.md#searchvoices) - Search voices.
|
|
148
212
|
* [getVoice](docs/sdks/voices/README.md#getvoice) - Get voice details by ID
|
|
149
213
|
|
|
214
|
+
</details>
|
|
150
215
|
<!-- End Available Resources and Operations [operations] -->
|
|
151
216
|
|
|
152
217
|
<!-- Start Error Handling [errors] -->
|
|
@@ -163,44 +228,10 @@ run();
|
|
|
163
228
|
| `error.rawResponse` | `Response` | Raw HTTP response |
|
|
164
229
|
| `error.data$` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
|
|
165
230
|
|
|
166
|
-
|
|
167
|
-
### Error Classes
|
|
168
|
-
**Primary error:**
|
|
169
|
-
* [`SupertoneError`](./src/models/errors/supertoneerror.ts): The base class for HTTP error responses.
|
|
170
|
-
|
|
171
|
-
<details><summary>Less common errors (16)</summary>
|
|
172
|
-
|
|
173
|
-
<br />
|
|
174
|
-
|
|
175
|
-
**Network errors:**
|
|
176
|
-
* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
|
|
177
|
-
* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
|
|
178
|
-
* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
|
|
179
|
-
* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
|
|
180
|
-
* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
**Inherit from [`SupertoneError`](./src/models/errors/supertoneerror.ts)**:
|
|
184
|
-
* [`UnauthorizedErrorResponse`](./src/models/errors/unauthorizederrorresponse.ts): Unauthorized: Invalid API key. Status code `401`. Applicable to 10 of 15 methods.*
|
|
185
|
-
* [`InternalServerErrorResponse`](./src/models/errors/internalservererrorresponse.ts): Status code `500`. Applicable to 10 of 15 methods.*
|
|
186
|
-
* [`NotFoundErrorResponse`](./src/models/errors/notfounderrorresponse.ts): Status code `404`. Applicable to 9 of 15 methods.*
|
|
187
|
-
* [`BadRequestErrorResponse`](./src/models/errors/badrequesterrorresponse.ts): Status code `400`. Applicable to 5 of 15 methods.*
|
|
188
|
-
* [`ForbiddenErrorResponse`](./src/models/errors/forbiddenerrorresponse.ts): Status code `403`. Applicable to 4 of 15 methods.*
|
|
189
|
-
* [`RequestTimeoutErrorResponse`](./src/models/errors/requesttimeouterrorresponse.ts): Status code `408`. Applicable to 4 of 15 methods.*
|
|
190
|
-
* [`TooManyRequestsErrorResponse`](./src/models/errors/toomanyrequestserrorresponse.ts): Status code `429`. Applicable to 4 of 15 methods.*
|
|
191
|
-
* [`PaymentRequiredErrorResponse`](./src/models/errors/paymentrequirederrorresponse.ts): Status code `402`. Applicable to 3 of 15 methods.*
|
|
192
|
-
* [`PayloadTooLargeErrorResponse`](./src/models/errors/payloadtoolargeerrorresponse.ts): Payload Too Large: File size exceeds 3MB limit. Status code `413`. Applicable to 1 of 15 methods.*
|
|
193
|
-
* [`UnsupportedMediaTypeErrorResponse`](./src/models/errors/unsupportedmediatypeerrorresponse.ts): Unsupported Media Type: Invalid audio file format. Status code `415`. Applicable to 1 of 15 methods.*
|
|
194
|
-
* [`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.
|
|
195
|
-
|
|
196
|
-
</details>
|
|
197
|
-
|
|
198
|
-
\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
|
|
199
|
-
|
|
200
|
-
### Error Handling Example
|
|
231
|
+
### Example
|
|
201
232
|
```typescript
|
|
202
|
-
import { Supertone } from "supertone";
|
|
203
|
-
import * as errors from "supertone/models/errors";
|
|
233
|
+
import { Supertone } from "@supertone/supertone";
|
|
234
|
+
import * as errors from "@supertone/supertone/models/errors";
|
|
204
235
|
|
|
205
236
|
const supertone = new Supertone({
|
|
206
237
|
apiKey: "<YOUR_API_KEY_HERE>",
|
|
@@ -238,9 +269,42 @@ run();
|
|
|
238
269
|
|
|
239
270
|
```
|
|
240
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.
|
|
241
304
|
<!-- End Error Handling [errors] -->
|
|
242
305
|
|
|
243
306
|
<!-- Start Additional Example Code [examples] -->
|
|
307
|
+
|
|
244
308
|
## Additional Example Code
|
|
245
309
|
|
|
246
310
|
Additional example code can be found in the [examples](https://github.com/supertone-inc/supertone-ts/tree/main/examples) directory.
|
|
@@ -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
|
/**
|