feat: support streaming API for TTS and STT models#36
feat: support streaming API for TTS and STT models#36thesaadmirza wants to merge 4 commits intogpustack:mainfrom
Conversation
Add streaming support to TTS (speech) and STT (transcriptions) endpoints. TTS streaming: - Add is_stream_supported() and speech_stream() to TTSBackend base class - Implement streaming in CosyVoice backend via inference_sft(stream=True) - Stream raw PCM int16 audio chunks (response_format=pcm required) STT streaming: - Add is_stream_supported() and transcribe_stream() to STTBackend base class - Implement streaming in FasterWhisper backend, yielding segments as JSON - Use Server-Sent Events format for text streaming API changes: - Add stream field to SpeechRequest (default: false) - Parse stream from transcription form data - Return StreamingResponse for streaming requests - Extract _parse_transcription_form() to keep endpoint complexity in check - Add sse_stream() helper for SSE formatting Ref: gpustack/gpustack#962
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces streaming capabilities to the Text-to-Speech (TTS) and Speech-to-Text (STT) API endpoints. This enhancement allows for the incremental delivery of audio or text as it is generated, significantly improving responsiveness for real-time applications by providing partial results sooner. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces streaming capabilities for both Text-to-Speech (TTS) and Speech-to-Text (STT) endpoints, which is a significant feature enhancement. For TTS, streaming is enabled via stream: true on the /v1/audio/speech endpoint, returning raw PCM data, with the CosyVoice backend updated to support this. For STT, the /v1/audio/transcriptions endpoint now supports streaming through Server-Sent Events, with an implementation provided for the FasterWhisper backend. The changes are well-structured, including necessary updates to base classes and a helpful refactoring of the form parsing logic in the router. My review includes a couple of suggestions to improve robustness and performance.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
gpustack/gpustack#962
Add streaming support to the TTS and STT endpoints so audio/text can be sent to the client incrementally as it's generated.
TTS (
/v1/audio/speech):stream: true+response_format: pcmreturns aStreamingResponseof raw PCM int16 chunksinference_sft(stream=True)STT (
/v1/audio/transcriptions):stream: truereturns Server-Sent Events with one JSON object per segmentNon-streaming behavior is unchanged.