feat: add OpenRouter as a speech (TTS) provider#1302
feat: add OpenRouter as a speech (TTS) provider#1302monolithic827 wants to merge 2 commits intomoeru-ai:mainfrom
Conversation
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 a significant enhancement by adding OpenRouter as a new speech provider, expanding the platform's text-to-speech capabilities. It ensures a robust and dynamic integration by fetching models on the fly and includes a crucial fix to prevent an existing race condition from affecting provider selection stability. Highlights
Changelog
Ignored Files
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 OpenRouter as a new text-to-speech provider, which is a great addition. The implementation cleverly uses the chat completions endpoint with audio modality to generate speech, including constructing a WAV header on the fly. The PR also includes a fix for a race condition in the speech store during provider validation.
My review focuses on improving code maintainability and robustness. I've suggested simplifying duplicated logic for handling the base URL, adding logging for silently handled errors, and improving the readability of the WAV header creation code. These changes should make the new provider implementation easier to understand and maintain.
f6377c6 to
076e7d3
Compare
Summary
/chat/completionsAPI with audio modality (modalities: ["text", "audio"]) since OpenRouter does not support the/audio/speechendpoint/models?output_modality=audioDetails
OpenRouter supports audio output through its chat completions API with streaming. The provider bridges this into the existing
SpeechProviderinterface using a customfetchthat:modalities: ["text", "audio"]andformat: "pcm16"delta.audio.dataFiles changed
packages/stage-ui/src/stores/providers.ts- newopenrouter-audio-speechprovider metadata entry; exposeproviderRuntimeStatepackages/stage-pages/src/pages/settings/providers/speech/openrouter-audio-speech.vue- settings page with model selector and speech playgroundpackages/i18n/src/locales/en/settings.yaml- i18n entriespackages/stage-ui/src/stores/modules/speech.ts- fix startup race condition that cleared persisted speech provider selection before validation ran