Skip to content

Conversation

@lgavincrl
Copy link
Contributor

TTS with streaming audio example from .py file

@lgavincrl lgavincrl requested a review from TudorCRL November 7, 2025 17:14
@lgavincrl lgavincrl marked this pull request as ready for review November 11, 2025 14:37
.gitignore Outdated
.claude

# Examples
**/output.wav
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**/output.wav
**/output.wav


async def audio_generator(audio_queue: asyncio.Queue, text: str, voice: str, output_format: str) -> None:
# Generate speech and stream audio chunks into the queue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

This producer function takes a string of text, fetches and decodes audio chunks from the Speechmatics TTS API, and converts the audio data into a queue of samples, ready for the audio player to consume.


# audio_player()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# audio_player()
### audio_player()


This example shows how to use the Speechmatics TTS API to generate audio from text and autoplay it using sounddevice through the systems default audio output device.
- User must have an audio output device configured on their system for this example to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a bit more explanation to this section, like in the suggestion below, to setup the explanation of the two main functions

Suggested change
## How it works
There are two main components etc.

Comment on lines 16 to 17


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


- `SPEECHMATICS_API_KEY`: Your Speechmatics API key


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -0,0 +1,29 @@
import asyncio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this file, it's already in the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants