@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.
Files changed (73) hide show
  1. package/FUNCTIONS.md +2 -2
  2. package/README.md +108 -44
  3. package/custom_test/realtime_tts_player.ts +64 -3
  4. package/custom_test/test_real_api.ts +1040 -105
  5. package/dist/commonjs/lib/config.d.ts +2 -2
  6. package/dist/commonjs/lib/config.d.ts.map +1 -1
  7. package/dist/commonjs/lib/config.js +2 -2
  8. package/dist/commonjs/lib/config.js.map +1 -1
  9. package/dist/commonjs/lib/custom_utils/text_utils.d.ts +8 -1
  10. package/dist/commonjs/lib/custom_utils/text_utils.d.ts.map +1 -1
  11. package/dist/commonjs/lib/custom_utils/text_utils.js +108 -7
  12. package/dist/commonjs/lib/custom_utils/text_utils.js.map +1 -1
  13. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.d.ts +92 -1
  14. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.d.ts.map +1 -1
  15. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.js +48 -3
  16. package/dist/commonjs/models/apiconverttexttospeechusingcharacterrequest.js.map +1 -1
  17. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.d.ts +92 -1
  18. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.d.ts.map +1 -1
  19. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.js +46 -3
  20. package/dist/commonjs/models/predictttsdurationusingcharacterrequest.js.map +1 -1
  21. package/dist/commonjs/sdk/texttospeech.d.ts.map +1 -1
  22. package/dist/commonjs/sdk/texttospeech.js +12 -9
  23. package/dist/commonjs/sdk/texttospeech.js.map +1 -1
  24. package/dist/esm/lib/config.d.ts +2 -2
  25. package/dist/esm/lib/config.d.ts.map +1 -1
  26. package/dist/esm/lib/config.js +2 -2
  27. package/dist/esm/lib/config.js.map +1 -1
  28. package/dist/esm/lib/custom_utils/text_utils.d.ts +8 -1
  29. package/dist/esm/lib/custom_utils/text_utils.d.ts.map +1 -1
  30. package/dist/esm/lib/custom_utils/text_utils.js +108 -7
  31. package/dist/esm/lib/custom_utils/text_utils.js.map +1 -1
  32. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.d.ts +92 -1
  33. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.d.ts.map +1 -1
  34. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.js +47 -2
  35. package/dist/esm/models/apiconverttexttospeechusingcharacterrequest.js.map +1 -1
  36. package/dist/esm/models/predictttsdurationusingcharacterrequest.d.ts +92 -1
  37. package/dist/esm/models/predictttsdurationusingcharacterrequest.d.ts.map +1 -1
  38. package/dist/esm/models/predictttsdurationusingcharacterrequest.js +45 -2
  39. package/dist/esm/models/predictttsdurationusingcharacterrequest.js.map +1 -1
  40. package/dist/esm/sdk/texttospeech.d.ts.map +1 -1
  41. package/dist/esm/sdk/texttospeech.js +12 -9
  42. package/dist/esm/sdk/texttospeech.js.map +1 -1
  43. package/examples/custom_voices/create_cloned_voice.ts +4 -3
  44. package/examples/custom_voices/delete_custom_voice.ts +2 -7
  45. package/examples/custom_voices/edit_custom_voice.ts +2 -6
  46. package/examples/custom_voices/get_custom_voice.ts +2 -7
  47. package/examples/custom_voices/list_custom_voices.ts +2 -7
  48. package/examples/custom_voices/search_custom_voices.ts +2 -6
  49. package/examples/package.json +2 -2
  50. package/examples/textToSpeechCreateSpeech.example.ts +2 -2
  51. package/examples/text_to_speech/create_speech.ts +3 -8
  52. package/examples/text_to_speech/create_speech_long_text.ts +3 -7
  53. package/examples/text_to_speech/create_speech_with_phonemes.ts +3 -7
  54. package/examples/text_to_speech/create_speech_with_voice_settings.ts +3 -8
  55. package/examples/text_to_speech/predict_duration.ts +3 -7
  56. package/examples/text_to_speech/stream_speech.ts +3 -7
  57. package/examples/text_to_speech/stream_speech_long_text.ts +3 -7
  58. package/examples/text_to_speech/stream_speech_with_phonemes.ts +3 -7
  59. package/examples/text_to_speech/stream_speech_with_voice_settings.ts +3 -7
  60. package/examples/usage/get_credit_balance.ts +2 -6
  61. package/examples/usage/get_usage.ts +2 -6
  62. package/examples/usage/get_voice_usage.ts +2 -7
  63. package/examples/voices/get_voice.ts +2 -6
  64. package/examples/voices/list_voices.ts +2 -6
  65. package/examples/voices/search_voices.ts +2 -7
  66. package/jsr.json +2 -2
  67. package/openapi.json +101 -9
  68. package/package.json +26 -10
  69. package/src/lib/config.ts +3 -2
  70. package/src/lib/custom_utils/text_utils.ts +117 -7
  71. package/src/models/apiconverttexttospeechusingcharacterrequest.ts +62 -3
  72. package/src/models/predictttsdurationusingcharacterrequest.ts +64 -3
  73. 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
- ![LOGO](https://github.com/supertone-inc/supertone-ts/blob/main/images/hero-light.svg)
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
- ## API & Docs
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
- ## Speech Generation Example
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: 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
  /**