Skip to content

Conversation

@lukeocodes
Copy link
Contributor

This pull request adds three new comprehensive example scripts showcasing the usage of the TextBuilder and related helper functions for Deepgram TTS. These examples cover interactive demonstrations, REST API integration, and real-time streaming via WebSocket, making it easier for developers to understand and utilize advanced TTS features such as custom pronunciations, pauses, SSML migration, validation, error handling, and API limits.

New Example Scripts Added:

TextBuilder demonstration and usage:

  • Added examples/22-text-builder-demo.py, an interactive script demonstrating all features of TextBuilder, including basic usage, helper functions, SSML conversion, validation, error handling, real-world scenarios, and a summary of API limits. No API key required; focuses on text formatting.

REST API integration:

  • Added examples/23-text-builder-helper.py, which shows how to use TextBuilder with the Deepgram REST API to generate audio files, including examples for basic usage, standalone helpers, SSML migration, mixed SSML/builder usage, and pharmacy instructions.

Streaming/WebSocket integration:

  • Added examples/24-text-builder-streaming.py, demonstrating how to use TextBuilder for real-time TTS audio generation via WebSocket, including streaming single and multiple messages and saving the resulting audio data.

…controls

- Add TextBuilder fluent builder class with text(), pronunciation(), pause(), from_ssml(), and build() methods
- Add standalone utility functions: add_pronunciation(), ssml_to_deepgram(), validate_ipa(), validate_pause()
- Implement comprehensive input validation and API limit enforcement (500 pronunciations, 50 pauses, 2000 chars)
- Support SSML parsing and conversion (phoneme and break tags)
- Include proper JSON escaping and error handling
- Export TextBuilder, add_pronunciation, ssml_to_deepgram, validate_ipa, and validate_pause from deepgram package
- Add to __all__ and _dynamic_imports for lazy loading
- Enable usage: from deepgram import TextBuilder
- Add 50+ test cases covering all TextBuilder functionality
- Test basic text, pronunciation, pause, and SSML conversion
- Test validation functions and error handling
- Test API limit enforcement (pronunciations, pauses, characters)
- Test standalone functions (add_pronunciation, ssml_to_deepgram)
- Include integration tests with real-world examples
- Add 25-text-builder-demo.py: interactive demonstration of all features (no API key required)
- Add 25-text-builder-helper.py: live TTS generation examples with API integration
- Include examples for basic usage, SSML migration, standalone functions, and real-world scenarios
- Cover medical prescriptions, pharmacy instructions, and scientific terminology use cases
- Add TextBuilder demo and helper examples to Text-to-Speech section
- Include both interactive demo (no API key) and live TTS generation examples
Renumber all examples to group by feature area, with each section starting at multiples of 10:

- 01-09: Authentication
- 10-19: Transcription (Listen)
- 20-29: Text-to-Speech (Speak) - including new TextBuilder streaming example
- 30-39: Voice Agent
- 40-49: Text Intelligence (Read)
- 50-59: Management API
- 60-69: On-Premises
- 70-79: Configuration & Advanced

This makes the examples easier to navigate and leaves room for future additions in each section.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lo/tts-helpers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Fix ssml_to_deepgram to handle SSML fragments (not just complete documents)
- Fix validate_pause to check integer type before increment validation
- Fix test case to use correct case-sensitive word matching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants