typecast-python 0.1.3__tar.gz → 0.1.5__tar.gz
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.
- {typecast_python-0.1.3 → typecast_python-0.1.5}/PKG-INFO +234 -115
- typecast_python-0.1.5/README.md +313 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/pyproject.toml +1 -1
- typecast_python-0.1.5/src/typecast/__init__.py +46 -0
- typecast_python-0.1.5/src/typecast/async_client.py +238 -0
- typecast_python-0.1.5/src/typecast/client.py +208 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/exceptions.py +7 -0
- typecast_python-0.1.5/src/typecast/models/__init__.py +45 -0
- typecast_python-0.1.5/src/typecast/models/tts.py +152 -0
- typecast_python-0.1.5/src/typecast/models/voices.py +77 -0
- typecast_python-0.1.3/README.md +0 -194
- typecast_python-0.1.3/src/typecast/__init__.py +0 -25
- typecast_python-0.1.3/src/typecast/async_client.py +0 -105
- typecast_python-0.1.3/src/typecast/client.py +0 -87
- typecast_python-0.1.3/src/typecast/models/__init__.py +0 -15
- typecast_python-0.1.3/src/typecast/models/tts.py +0 -80
- typecast_python-0.1.3/src/typecast/models/voices.py +0 -9
- {typecast_python-0.1.3 → typecast_python-0.1.5}/.gitignore +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/LICENSE +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/conf.py +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/models/error.py +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/models/tts_wss.py +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/sse.py +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/utils.py +0 -0
- {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/websocket.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: typecast-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Official Typecast Python SDK - Convert text to lifelike speech using AI-powered voices
|
|
5
5
|
Project-URL: Homepage, https://typecast.ai
|
|
6
6
|
Project-URL: Documentation, https://typecast.ai/docs/overview
|
|
@@ -239,11 +239,40 @@ Requires-Dist: pytest-mock>=3.14.0; extra == 'dev'
|
|
|
239
239
|
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
240
240
|
Description-Content-Type: text/markdown
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
<div align="center">
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
# Typecast SDK for Python
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
**The official Python SDK for the Typecast Text-to-Speech API**
|
|
247
|
+
|
|
248
|
+
Convert text to lifelike speech using AI-powered voices
|
|
249
|
+
|
|
250
|
+
[](https://pypi.org/project/typecast-python/)
|
|
251
|
+
[](LICENSE)
|
|
252
|
+
[](https://www.python.org/)
|
|
253
|
+
|
|
254
|
+
[Documentation](https://typecast.ai/docs) | [API Reference](https://typecast.ai/docs/api-reference) | [Get API Key](https://typecast.ai/developers/api/api-key)
|
|
255
|
+
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Table of Contents
|
|
261
|
+
|
|
262
|
+
- [Installation](#installation)
|
|
263
|
+
- [Quick Start](#quick-start)
|
|
264
|
+
- [Features](#features)
|
|
265
|
+
- [Usage](#usage)
|
|
266
|
+
- [Configuration](#configuration)
|
|
267
|
+
- [Text to Speech](#text-to-speech)
|
|
268
|
+
- [Voice Discovery](#voice-discovery)
|
|
269
|
+
- [Emotion Control](#emotion-control)
|
|
270
|
+
- [Async Client](#async-client)
|
|
271
|
+
- [Supported Languages](#supported-languages)
|
|
272
|
+
- [Error Handling](#error-handling)
|
|
273
|
+
- [License](#license)
|
|
274
|
+
|
|
275
|
+
---
|
|
247
276
|
|
|
248
277
|
## Installation
|
|
249
278
|
|
|
@@ -251,185 +280,275 @@ For comprehensive API documentation, visit [Typecast Documentation](https://type
|
|
|
251
280
|
pip install typecast-python
|
|
252
281
|
```
|
|
253
282
|
|
|
283
|
+
---
|
|
284
|
+
|
|
254
285
|
## Quick Start
|
|
255
286
|
|
|
256
287
|
```python
|
|
257
|
-
from typecast
|
|
288
|
+
from typecast import Typecast
|
|
258
289
|
from typecast.models import TTSRequest
|
|
259
290
|
|
|
260
|
-
|
|
261
|
-
cli = Typecast(api_key="YOUR_API_KEY")
|
|
291
|
+
client = Typecast(api_key="YOUR_API_KEY")
|
|
262
292
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
voice_id="tc_62a8975e695ad26f7fb514d1"
|
|
293
|
+
response = client.text_to_speech(TTSRequest(
|
|
294
|
+
text="Hello! I'm your friendly text-to-speech assistant.",
|
|
295
|
+
model="ssfm-v30",
|
|
296
|
+
voice_id="tc_672c5f5ce59fac2a48faeaee"
|
|
268
297
|
))
|
|
269
298
|
|
|
270
|
-
|
|
271
|
-
with open('output.wav', 'wb') as f:
|
|
299
|
+
with open("output.wav", "wb") as f:
|
|
272
300
|
f.write(response.audio_data)
|
|
273
301
|
|
|
274
|
-
print(f"
|
|
302
|
+
print(f"Saved: output.wav ({response.duration}s)")
|
|
275
303
|
```
|
|
276
304
|
|
|
305
|
+
---
|
|
306
|
+
|
|
277
307
|
## Features
|
|
278
308
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
309
|
+
| Feature | Description |
|
|
310
|
+
|---------|-------------|
|
|
311
|
+
| **Multiple Models** | Support for `ssfm-v21` and `ssfm-v30` AI voice models |
|
|
312
|
+
| **37 Languages** | English, Korean, Japanese, Chinese, Spanish, and 32 more |
|
|
313
|
+
| **Emotion Control** | Preset emotions or smart context-aware inference |
|
|
314
|
+
| **Audio Customization** | Volume, pitch, tempo, and format (WAV/MP3) |
|
|
315
|
+
| **Voice Discovery** | Filter voices by model, gender, age, and use cases |
|
|
316
|
+
| **Async Support** | Built-in async client for high-performance applications |
|
|
317
|
+
| **Type Hints** | Full type annotations with Pydantic models |
|
|
318
|
+
|
|
319
|
+
---
|
|
285
320
|
|
|
286
|
-
##
|
|
321
|
+
## Usage
|
|
287
322
|
|
|
288
|
-
###
|
|
323
|
+
### Configuration
|
|
289
324
|
|
|
290
325
|
```python
|
|
291
|
-
from typecast
|
|
292
|
-
from typecast.models import TTSRequest, Prompt, Output
|
|
326
|
+
from typecast import Typecast
|
|
293
327
|
|
|
294
|
-
|
|
328
|
+
# Using environment variable (recommended)
|
|
329
|
+
# export TYPECAST_API_KEY="your-api-key"
|
|
330
|
+
client = Typecast()
|
|
295
331
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
332
|
+
# Or pass directly
|
|
333
|
+
client = Typecast(
|
|
334
|
+
api_key="your-api-key",
|
|
335
|
+
host="https://api.typecast.ai" # optional
|
|
336
|
+
)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Text to Speech
|
|
340
|
+
|
|
341
|
+
#### Basic Usage
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
from typecast.models import TTSRequest
|
|
345
|
+
|
|
346
|
+
response = client.text_to_speech(TTSRequest(
|
|
347
|
+
text="Hello, world!",
|
|
348
|
+
voice_id="tc_672c5f5ce59fac2a48faeaee",
|
|
349
|
+
model="ssfm-v30"
|
|
350
|
+
))
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### With Audio Options
|
|
354
|
+
|
|
355
|
+
```python
|
|
356
|
+
from typecast.models import TTSRequest, Output
|
|
357
|
+
|
|
358
|
+
response = client.text_to_speech(TTSRequest(
|
|
359
|
+
text="Hello, world!",
|
|
360
|
+
voice_id="tc_672c5f5ce59fac2a48faeaee",
|
|
361
|
+
model="ssfm-v30",
|
|
300
362
|
language="eng",
|
|
301
|
-
prompt=Prompt(
|
|
302
|
-
emotion_preset="happy", # Options: normal, happy, sad, angry
|
|
303
|
-
emotion_intensity=1.5 # Range: 0.0 to 2.0
|
|
304
|
-
),
|
|
305
363
|
output=Output(
|
|
306
|
-
volume=120,
|
|
307
|
-
audio_pitch=2,
|
|
308
|
-
audio_tempo=1.2,
|
|
309
|
-
audio_format="mp3"
|
|
364
|
+
volume=120, # 0-200 (default: 100)
|
|
365
|
+
audio_pitch=2, # -12 to +12 semitones
|
|
366
|
+
audio_tempo=1.2, # 0.5x to 2.0x
|
|
367
|
+
audio_format="mp3" # "wav" or "mp3"
|
|
310
368
|
),
|
|
311
|
-
seed=42
|
|
369
|
+
seed=42 # for reproducible results
|
|
312
370
|
))
|
|
313
371
|
```
|
|
314
372
|
|
|
315
373
|
### Voice Discovery
|
|
316
374
|
|
|
317
375
|
```python
|
|
318
|
-
|
|
319
|
-
|
|
376
|
+
from typecast.models import VoicesV2Filter, TTSModel, GenderEnum, AgeEnum
|
|
377
|
+
|
|
378
|
+
# Get all voices (V2 API - recommended)
|
|
379
|
+
voices = client.voices_v2()
|
|
320
380
|
|
|
321
|
-
# Filter by
|
|
322
|
-
|
|
381
|
+
# Filter by criteria
|
|
382
|
+
filtered = client.voices_v2(VoicesV2Filter(
|
|
383
|
+
model=TTSModel.SSFM_V30,
|
|
384
|
+
gender=GenderEnum.FEMALE,
|
|
385
|
+
age=AgeEnum.YOUNG_ADULT
|
|
386
|
+
))
|
|
323
387
|
|
|
324
|
-
#
|
|
325
|
-
|
|
326
|
-
print(f"
|
|
327
|
-
print(f"
|
|
388
|
+
# Display voice info
|
|
389
|
+
print(f"Name: {voices[0].voice_name}")
|
|
390
|
+
print(f"Gender: {voices[0].gender}, Age: {voices[0].age}")
|
|
391
|
+
print(f"Models: {', '.join(m.version.value for m in voices[0].models)}")
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Emotion Control
|
|
395
|
+
|
|
396
|
+
#### ssfm-v21: Basic Emotion
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
from typecast.models import TTSRequest, Prompt
|
|
400
|
+
|
|
401
|
+
response = client.text_to_speech(TTSRequest(
|
|
402
|
+
text="I'm so excited!",
|
|
403
|
+
voice_id="tc_62a8975e695ad26f7fb514d1",
|
|
404
|
+
model="ssfm-v21",
|
|
405
|
+
prompt=Prompt(
|
|
406
|
+
emotion_preset="happy", # normal, happy, sad, angry
|
|
407
|
+
emotion_intensity=1.5 # 0.0 to 2.0
|
|
408
|
+
)
|
|
409
|
+
))
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### ssfm-v30: Preset Mode
|
|
413
|
+
|
|
414
|
+
```python
|
|
415
|
+
from typecast.models import TTSRequest, PresetPrompt, TTSModel
|
|
416
|
+
|
|
417
|
+
response = client.text_to_speech(TTSRequest(
|
|
418
|
+
text="I'm so excited!",
|
|
419
|
+
voice_id="tc_672c5f5ce59fac2a48faeaee",
|
|
420
|
+
model=TTSModel.SSFM_V30,
|
|
421
|
+
prompt=PresetPrompt(
|
|
422
|
+
emotion_type="preset",
|
|
423
|
+
emotion_preset="happy", # normal, happy, sad, angry, whisper, toneup, tonedown
|
|
424
|
+
emotion_intensity=1.5
|
|
425
|
+
)
|
|
426
|
+
))
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
#### ssfm-v30: Smart Mode (Context-Aware)
|
|
430
|
+
|
|
431
|
+
```python
|
|
432
|
+
from typecast.models import TTSRequest, SmartPrompt, TTSModel
|
|
433
|
+
|
|
434
|
+
response = client.text_to_speech(TTSRequest(
|
|
435
|
+
text="Everything is perfect.",
|
|
436
|
+
voice_id="tc_672c5f5ce59fac2a48faeaee",
|
|
437
|
+
model=TTSModel.SSFM_V30,
|
|
438
|
+
prompt=SmartPrompt(
|
|
439
|
+
emotion_type="smart",
|
|
440
|
+
previous_text="I just got the best news!",
|
|
441
|
+
next_text="I can't wait to celebrate!"
|
|
442
|
+
)
|
|
443
|
+
))
|
|
328
444
|
```
|
|
329
445
|
|
|
330
446
|
### Async Client
|
|
331
447
|
|
|
332
448
|
```python
|
|
333
449
|
import asyncio
|
|
334
|
-
from typecast
|
|
335
|
-
from typecast.models import TTSRequest
|
|
450
|
+
from typecast import AsyncTypecast
|
|
451
|
+
from typecast.models import TTSRequest
|
|
336
452
|
|
|
337
453
|
async def main():
|
|
338
|
-
async with AsyncTypecast() as
|
|
339
|
-
response = await
|
|
454
|
+
async with AsyncTypecast(api_key="YOUR_API_KEY") as client:
|
|
455
|
+
response = await client.text_to_speech(TTSRequest(
|
|
340
456
|
text="Hello from async!",
|
|
341
|
-
model="ssfm-
|
|
342
|
-
voice_id="
|
|
343
|
-
language=LanguageCode.ENG
|
|
457
|
+
model="ssfm-v30",
|
|
458
|
+
voice_id="tc_672c5f5ce59fac2a48faeaee"
|
|
344
459
|
))
|
|
345
|
-
|
|
346
|
-
with open(
|
|
460
|
+
|
|
461
|
+
with open("output.wav", "wb") as f:
|
|
347
462
|
f.write(response.audio_data)
|
|
348
463
|
|
|
349
464
|
asyncio.run(main())
|
|
350
465
|
```
|
|
351
466
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
The SDK supports 27 languages with ISO 639-3 codes:
|
|
467
|
+
---
|
|
355
468
|
|
|
356
|
-
|
|
357
|
-
|----------|------|----------|------|----------|------|
|
|
358
|
-
| English | `eng` | Japanese | `jpn` | Ukrainian | `ukr` |
|
|
359
|
-
| Korean | `kor` | Greek | `ell` | Indonesian | `ind` |
|
|
360
|
-
| Spanish | `spa` | Tamil | `tam` | Danish | `dan` |
|
|
361
|
-
| German | `deu` | Tagalog | `tgl` | Swedish | `swe` |
|
|
362
|
-
| French | `fra` | Finnish | `fin` | Malay | `msa` |
|
|
363
|
-
| Italian | `ita` | Chinese | `zho` | Czech | `ces` |
|
|
364
|
-
| Polish | `pol` | Slovak | `slk` | Portuguese | `por` |
|
|
365
|
-
| Dutch | `nld` | Arabic | `ara` | Bulgarian | `bul` |
|
|
366
|
-
| Russian | `rus` | Croatian | `hrv` | Romanian | `ron` |
|
|
469
|
+
## Supported Languages
|
|
367
470
|
|
|
368
|
-
|
|
471
|
+
<details>
|
|
472
|
+
<summary><strong>View all 37 supported languages</strong></summary>
|
|
473
|
+
|
|
474
|
+
| Code | Language | Code | Language | Code | Language |
|
|
475
|
+
|------|----------|------|----------|------|----------|
|
|
476
|
+
| `eng` | English | `jpn` | Japanese | `ukr` | Ukrainian |
|
|
477
|
+
| `kor` | Korean | `ell` | Greek | `ind` | Indonesian |
|
|
478
|
+
| `spa` | Spanish | `tam` | Tamil | `dan` | Danish |
|
|
479
|
+
| `deu` | German | `tgl` | Tagalog | `swe` | Swedish |
|
|
480
|
+
| `fra` | French | `fin` | Finnish | `msa` | Malay |
|
|
481
|
+
| `ita` | Italian | `zho` | Chinese | `ces` | Czech |
|
|
482
|
+
| `pol` | Polish | `slk` | Slovak | `por` | Portuguese |
|
|
483
|
+
| `nld` | Dutch | `ara` | Arabic | `bul` | Bulgarian |
|
|
484
|
+
| `rus` | Russian | `hrv` | Croatian | `ron` | Romanian |
|
|
485
|
+
| `ben` | Bengali | `hin` | Hindi | `hun` | Hungarian |
|
|
486
|
+
| `nan` | Hokkien | `nor` | Norwegian | `pan` | Punjabi |
|
|
487
|
+
| `tha` | Thai | `tur` | Turkish | `vie` | Vietnamese |
|
|
488
|
+
| `yue` | Cantonese | | | | |
|
|
489
|
+
|
|
490
|
+
</details>
|
|
369
491
|
|
|
370
492
|
```python
|
|
371
493
|
from typecast.models import LanguageCode
|
|
372
494
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
...
|
|
377
|
-
|
|
495
|
+
# Auto-detect (recommended)
|
|
496
|
+
response = client.text_to_speech(TTSRequest(
|
|
497
|
+
text="こんにちは",
|
|
498
|
+
voice_id="...",
|
|
499
|
+
model="ssfm-v30"
|
|
500
|
+
))
|
|
501
|
+
|
|
502
|
+
# Explicit language
|
|
503
|
+
response = client.text_to_speech(TTSRequest(
|
|
504
|
+
text="안녕하세요",
|
|
505
|
+
voice_id="...",
|
|
506
|
+
model="ssfm-v30",
|
|
507
|
+
language=LanguageCode.KOR
|
|
508
|
+
))
|
|
378
509
|
```
|
|
379
510
|
|
|
380
|
-
|
|
511
|
+
---
|
|
381
512
|
|
|
382
|
-
|
|
513
|
+
## Error Handling
|
|
383
514
|
|
|
384
515
|
```python
|
|
385
|
-
from typecast
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
516
|
+
from typecast import (
|
|
517
|
+
Typecast,
|
|
518
|
+
TypecastError,
|
|
519
|
+
BadRequestError,
|
|
520
|
+
UnauthorizedError,
|
|
521
|
+
PaymentRequiredError,
|
|
522
|
+
NotFoundError,
|
|
523
|
+
UnprocessableEntityError,
|
|
524
|
+
RateLimitError,
|
|
525
|
+
InternalServerError,
|
|
393
526
|
)
|
|
394
527
|
|
|
395
528
|
try:
|
|
396
|
-
response =
|
|
529
|
+
response = client.text_to_speech(request)
|
|
397
530
|
except UnauthorizedError:
|
|
398
531
|
print("Invalid API key")
|
|
399
532
|
except PaymentRequiredError:
|
|
400
533
|
print("Insufficient credits")
|
|
534
|
+
except RateLimitError:
|
|
535
|
+
print("Rate limit exceeded - please retry later")
|
|
401
536
|
except TypecastError as e:
|
|
402
|
-
print(f"Error
|
|
537
|
+
print(f"Error {e.status_code}: {e.message}")
|
|
403
538
|
```
|
|
404
539
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
## Configuration
|
|
540
|
+
| Exception | Status Code | Description |
|
|
541
|
+
|-----------|-------------|-------------|
|
|
542
|
+
| `BadRequestError` | 400 | Invalid request parameters |
|
|
543
|
+
| `UnauthorizedError` | 401 | Invalid or missing API key |
|
|
544
|
+
| `PaymentRequiredError` | 402 | Insufficient credits |
|
|
545
|
+
| `NotFoundError` | 404 | Resource not found |
|
|
546
|
+
| `UnprocessableEntityError` | 422 | Validation error |
|
|
547
|
+
| `RateLimitError` | 429 | Rate limit exceeded |
|
|
548
|
+
| `InternalServerError` | 500 | Server error |
|
|
415
549
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
```bash
|
|
419
|
-
export TYPECAST_API_KEY="your-api-key-here"
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
```python
|
|
423
|
-
# From environment variable
|
|
424
|
-
cli = Typecast()
|
|
425
|
-
|
|
426
|
-
# Or pass directly
|
|
427
|
-
cli = Typecast(api_key="your-api-key-here")
|
|
428
|
-
|
|
429
|
-
# Custom host (optional)
|
|
430
|
-
cli = Typecast(host="https://custom-api.example.com")
|
|
431
|
-
```
|
|
550
|
+
---
|
|
432
551
|
|
|
433
552
|
## License
|
|
434
553
|
|
|
435
|
-
Apache
|
|
554
|
+
[Apache-2.0](LICENSE) © [Neosapience](https://typecast.ai)
|