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.
Files changed (25) hide show
  1. {typecast_python-0.1.3 → typecast_python-0.1.5}/PKG-INFO +234 -115
  2. typecast_python-0.1.5/README.md +313 -0
  3. {typecast_python-0.1.3 → typecast_python-0.1.5}/pyproject.toml +1 -1
  4. typecast_python-0.1.5/src/typecast/__init__.py +46 -0
  5. typecast_python-0.1.5/src/typecast/async_client.py +238 -0
  6. typecast_python-0.1.5/src/typecast/client.py +208 -0
  7. {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/exceptions.py +7 -0
  8. typecast_python-0.1.5/src/typecast/models/__init__.py +45 -0
  9. typecast_python-0.1.5/src/typecast/models/tts.py +152 -0
  10. typecast_python-0.1.5/src/typecast/models/voices.py +77 -0
  11. typecast_python-0.1.3/README.md +0 -194
  12. typecast_python-0.1.3/src/typecast/__init__.py +0 -25
  13. typecast_python-0.1.3/src/typecast/async_client.py +0 -105
  14. typecast_python-0.1.3/src/typecast/client.py +0 -87
  15. typecast_python-0.1.3/src/typecast/models/__init__.py +0 -15
  16. typecast_python-0.1.3/src/typecast/models/tts.py +0 -80
  17. typecast_python-0.1.3/src/typecast/models/voices.py +0 -9
  18. {typecast_python-0.1.3 → typecast_python-0.1.5}/.gitignore +0 -0
  19. {typecast_python-0.1.3 → typecast_python-0.1.5}/LICENSE +0 -0
  20. {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/conf.py +0 -0
  21. {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/models/error.py +0 -0
  22. {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/models/tts_wss.py +0 -0
  23. {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/sse.py +0 -0
  24. {typecast_python-0.1.3 → typecast_python-0.1.5}/src/typecast/utils.py +0 -0
  25. {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
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
- # Typecast Python SDK
242
+ <div align="center">
243
243
 
244
- Python SDK for Typecast API integration. Convert text to lifelike speech using AI-powered voices with emotion, pitch, and tempo control.
244
+ # Typecast SDK for Python
245
245
 
246
- For comprehensive API documentation, visit [Typecast Documentation](https://typecast.ai/docs/overview).
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
+ [![PyPI version](https://img.shields.io/pypi/v/typecast-python.svg?style=flat-square)](https://pypi.org/project/typecast-python/)
251
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg?style=flat-square)](LICENSE)
252
+ [![Python](https://img.shields.io/badge/Python-3.9+-3776ab.svg?style=flat-square&logo=python&logoColor=white)](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.client import Typecast
288
+ from typecast import Typecast
258
289
  from typecast.models import TTSRequest
259
290
 
260
- # Initialize client
261
- cli = Typecast(api_key="YOUR_API_KEY")
291
+ client = Typecast(api_key="YOUR_API_KEY")
262
292
 
263
- # Convert text to speech
264
- response = cli.text_to_speech(TTSRequest(
265
- text="Hello there! I'm your friendly text-to-speech agent.",
266
- model="ssfm-v21",
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
- # Save audio file
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"Duration: {response.duration}s, Format: {response.format}")
302
+ print(f"Saved: output.wav ({response.duration}s)")
275
303
  ```
276
304
 
305
+ ---
306
+
277
307
  ## Features
278
308
 
279
- - 🎙️ **Multiple Voice Models**: Support for various AI voice models (ssfm-v21, v20, etc.)
280
- - 🌍 **Multi-language Support**: 27+ languages including English, Korean, Spanish, Japanese, Chinese, and more
281
- - 😊 **Emotion Control**: Adjust emotional expression (happy, sad, angry, normal) with intensity control
282
- - 🎚️ **Audio Customization**: Control volume, pitch, tempo, and output format (WAV/MP3)
283
- - **Async Support**: Built-in async client for high-performance applications
284
- - 🔍 **Voice Discovery**: List and search available voices by model
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
- ## Advanced Usage
321
+ ## Usage
287
322
 
288
- ### Emotion and Audio Control
323
+ ### Configuration
289
324
 
290
325
  ```python
291
- from typecast.client import Typecast
292
- from typecast.models import TTSRequest, Prompt, Output
326
+ from typecast import Typecast
293
327
 
294
- cli = Typecast()
328
+ # Using environment variable (recommended)
329
+ # export TYPECAST_API_KEY="your-api-key"
330
+ client = Typecast()
295
331
 
296
- response = cli.text_to_speech(TTSRequest(
297
- text="I am so excited to show you these features!",
298
- model="ssfm-v21",
299
- voice_id="tc_62a8975e695ad26f7fb514d1",
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, # Range: 0 to 200
307
- audio_pitch=2, # Range: -12 to +12 semitones
308
- audio_tempo=1.2, # Range: 0.5x to 2.0x
309
- audio_format="mp3" # Options: wav, 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 # For reproducible results
369
+ seed=42 # for reproducible results
312
370
  ))
313
371
  ```
314
372
 
315
373
  ### Voice Discovery
316
374
 
317
375
  ```python
318
- # List all voices
319
- voices = cli.voices()
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 model
322
- v21_voices = cli.voices(model="ssfm-v21")
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
- # Get specific voice
325
- voice = cli.get_voice("tc_62a8975e695ad26f7fb514d1")
326
- print(f"Voice: {voice.voice_name}")
327
- print(f"Available emotions: {voice.emotions}")
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.async_client import AsyncTypecast
335
- from typecast.models import TTSRequest, LanguageCode
450
+ from typecast import AsyncTypecast
451
+ from typecast.models import TTSRequest
336
452
 
337
453
  async def main():
338
- async with AsyncTypecast() as cli:
339
- response = await cli.text_to_speech(TTSRequest(
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-v21",
342
- voice_id="tc_62a8975e695ad26f7fb514d1",
343
- language=LanguageCode.ENG
457
+ model="ssfm-v30",
458
+ voice_id="tc_672c5f5ce59fac2a48faeaee"
344
459
  ))
345
-
346
- with open('async_output.wav', 'wb') as f:
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
- ## Supported Languages
353
-
354
- The SDK supports 27 languages with ISO 639-3 codes:
467
+ ---
355
468
 
356
- | Language | Code | Language | Code | Language | Code |
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
- Use the `LanguageCode` enum for type-safe language selection:
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
- request = TTSRequest(
374
- text="Hello",
375
- language=LanguageCode.ENG,
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
- ## Error Handling
511
+ ---
381
512
 
382
- The SDK provides specific exceptions for different HTTP status codes:
513
+ ## Error Handling
383
514
 
384
515
  ```python
385
- from typecast.exceptions import (
386
- BadRequestError, # 400
387
- UnauthorizedError, # 401
388
- PaymentRequiredError, # 402
389
- NotFoundError, # 404
390
- UnprocessableEntityError, # 422
391
- InternalServerError, # 500
392
- TypecastError # Base exception
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 = cli.text_to_speech(request)
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: {e.message}, Status: {e.status_code}")
537
+ print(f"Error {e.status_code}: {e.message}")
403
538
  ```
404
539
 
405
- ## Examples
406
-
407
- Check out the [examples](./examples) directory for more usage examples:
408
-
409
- - [`simple.py`](./examples/simple.py) - Basic text-to-speech conversion
410
- - [`advanced.py`](./examples/advanced.py) - Emotion, pitch, and tempo control
411
- - [`voices_example.py`](./examples/voices_example.py) - Discovering available voices
412
- - [`async_example.py`](./examples/async_example.py) - Async client usage
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
- Set your API key via environment variable or constructor:
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 License 2.0
554
+ [Apache-2.0](LICENSE) © [Neosapience](https://typecast.ai)