@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.
Files changed (59) hide show
  1. package/README.md +123 -73
  2. package/custom_test/realtime_tts_player.ts +64 -3
  3. package/custom_test/test_real_api.ts +1040 -105
  4. package/dist/commonjs/lib/config.d.ts +2 -2
  5. package/dist/commonjs/lib/config.js +2 -2
  6. package/dist/commonjs/lib/custom_utils/text_utils.d.ts +8 -1
  7. package/dist/commonjs/lib/custom_utils/text_utils.d.ts.map +1 -1
  8. package/dist/commonjs/lib/custom_utils/text_utils.js +108 -7
  9. package/dist/commonjs/lib/custom_utils/text_utils.js.map +1 -1
  10. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.d.ts +92 -1
  11. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.d.ts.map +1 -1
  12. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.js +48 -3
  13. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.js.map +1 -1
  14. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.d.ts +92 -1
  15. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.d.ts.map +1 -1
  16. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.js +46 -3
  17. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.js.map +1 -1
  18. package/dist/esm/lib/config.d.ts +2 -2
  19. package/dist/esm/lib/config.js +2 -2
  20. package/dist/esm/lib/custom_utils/text_utils.d.ts +8 -1
  21. package/dist/esm/lib/custom_utils/text_utils.d.ts.map +1 -1
  22. package/dist/esm/lib/custom_utils/text_utils.js +108 -7
  23. package/dist/esm/lib/custom_utils/text_utils.js.map +1 -1
  24. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.d.ts +92 -1
  25. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.d.ts.map +1 -1
  26. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.js +47 -2
  27. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.js.map +1 -1
  28. package/dist/esm/models/predictttsdurationusingcharacterrequest.d.ts +92 -1
  29. package/dist/esm/models/predictttsdurationusingcharacterrequest.d.ts.map +1 -1
  30. package/dist/esm/models/predictttsdurationusingcharacterrequest.js +45 -2
  31. package/dist/esm/models/predictttsdurationusingcharacterrequest.js.map +1 -1
  32. package/examples/custom_voices/create_cloned_voice.ts +4 -3
  33. package/examples/custom_voices/delete_custom_voice.ts +2 -7
  34. package/examples/custom_voices/edit_custom_voice.ts +2 -6
  35. package/examples/custom_voices/get_custom_voice.ts +2 -7
  36. package/examples/custom_voices/list_custom_voices.ts +2 -7
  37. package/examples/custom_voices/search_custom_voices.ts +2 -6
  38. package/examples/text_to_speech/create_speech.ts +3 -8
  39. package/examples/text_to_speech/create_speech_long_text.ts +3 -7
  40. package/examples/text_to_speech/create_speech_with_phonemes.ts +3 -7
  41. package/examples/text_to_speech/create_speech_with_voice_settings.ts +3 -8
  42. package/examples/text_to_speech/predict_duration.ts +3 -7
  43. package/examples/text_to_speech/stream_speech.ts +3 -7
  44. package/examples/text_to_speech/stream_speech_long_text.ts +3 -7
  45. package/examples/text_to_speech/stream_speech_with_phonemes.ts +3 -7
  46. package/examples/text_to_speech/stream_speech_with_voice_settings.ts +3 -7
  47. package/examples/usage/get_credit_balance.ts +2 -6
  48. package/examples/usage/get_usage.ts +2 -6
  49. package/examples/usage/get_voice_usage.ts +2 -7
  50. package/examples/voices/get_voice.ts +2 -6
  51. package/examples/voices/list_voices.ts +2 -6
  52. package/examples/voices/search_voices.ts +2 -7
  53. package/jsr.json +1 -1
  54. package/openapi.json +101 -9
  55. package/package.json +1 -1
  56. package/src/lib/config.ts +2 -2
  57. package/src/lib/custom_utils/text_utils.ts +117 -7
  58. package/src/models/apiconverttexttospeechusingcharacterrequest.ts +62 -3
  59. package/src/models/predictttsdurationusingcharacterrequest.ts +64 -3
package/README.md CHANGED
@@ -3,15 +3,12 @@
3
3
  ![LOGO](https://github.com/supertone-inc/supertone-ts/blob/main/images/hero-light.png?raw=true)
4
4
 
5
5
  <!-- Start Summary [summary] -->
6
+ ## Summary
6
7
 
7
- ## API & Docs
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 @supertone/supertone
19
+ npm add <UNSET>
23
20
  ```
24
21
 
25
22
  ### PNPM
26
23
 
27
24
  ```bash
28
- pnpm add @supertone/supertone
25
+ pnpm add <UNSET>
29
26
  ```
30
27
 
31
28
  ### Bun
32
29
 
33
30
  ```bash
34
- bun add @supertone/supertone
31
+ bun add <UNSET>
35
32
  ```
36
33
 
37
34
  ### Yarn
38
35
 
39
36
  ```bash
40
- yarn add @supertone/supertone zod
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 Available Resources and Operations [operations] -->
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
- - [createClonedVoice](docs/sdks/customvoices/README.md#createclonedvoice) - Create cloned voice
136
- - [listCustomVoices](docs/sdks/customvoices/README.md#listcustomvoices) - Gets custom (cloned) voices
137
- - [searchCustomVoices](docs/sdks/customvoices/README.md#searchcustomvoices) - Search custom (cloned) voices
138
- - [getCustomVoice](docs/sdks/customvoices/README.md#getcustomvoice) - Get single cloned voice
139
- - [editCustomVoice](docs/sdks/customvoices/README.md#editcustomvoice) - Update cloned voice (partial update)
140
- - [deleteCustomVoice](docs/sdks/customvoices/README.md#deletecustomvoice) - Delete cloned voice
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
- - [createSpeech](docs/sdks/texttospeech/README.md#createspeech) - Convert text to speech
145
- - [streamSpeech](docs/sdks/texttospeech/README.md#streamspeech) - Convert text to speech with streaming response
146
- - [predictDuration](docs/sdks/texttospeech/README.md#predictduration) - Predict text-to-speech duration
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
- - [getVoiceUsage](docs/sdks/usage/README.md#getvoiceusage) - Retrieve TTS API usage data
151
- - [getUsage](docs/sdks/usage/README.md#getusage) - Retrieve advanced API usage analytics
152
- - [getCreditBalance](docs/sdks/usage/README.md#getcreditbalance) - Retrieve credit balance
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
- - [listVoices](docs/sdks/voices/README.md#listvoices) - Gets available voices
157
- - [searchVoices](docs/sdks/voices/README.md#searchvoices) - Search voices.
158
- - [getVoice](docs/sdks/voices/README.md#getvoice) - Get voice details by ID
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
- ### Error Classes
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: models.APIConvertTextToSpeechUsingCharacterRequestLanguage.Ko,
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
  /**