[PR #5268] [CLOSED] feat: Add OpenAI API compatible STT provider #5382

Closed
opened 2026-06-05 15:21:10 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5268
Author: @angelplusultra
Created: 3/25/2026
Status: Closed

Base: masterHead: stt-provider-expansion-openai-api-compatible


📝 Commits (6)

  • 684f144 implement generic openai stt provider
  • a7bf476 simplify server.jsx
  • f1289ee lint and formatting
  • 7f1f2bd fix incorrect extension names
  • 47e147d cleanup audioContext in endSTTSession
  • afd3b44 add loading state for microphone getUserMedia

📊 Changes

13 files changed (+623 additions, -148 deletions)

View changed files

frontend/src/components/SpeechToText/OpenAiGenericOptions/index.jsx (+70 -0)
📝 frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SpeechToText/index.jsx (+19 -135)
frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SpeechToText/native.jsx (+146 -0)
frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SpeechToText/server.jsx (+208 -0)
📝 frontend/src/components/WorkspaceChat/ChatContainer/index.jsx (+4 -13)
📝 frontend/src/models/system.js (+14 -0)
📝 frontend/src/pages/GeneralSettings/AudioPreference/stt.jsx (+10 -0)
📝 server/.env.example (+6 -0)
📝 server/endpoints/system.js (+45 -0)
📝 server/models/systemSettings.js (+7 -0)
server/utils/SpeechToText/index.js (+14 -0)
server/utils/SpeechToText/openAiGeneric/index.js (+57 -0)
📝 server/utils/helpers/updateENV.js (+23 -0)

📄 Description

Pull Request Type

  • feat (New feature)
  • 🐛 fix (Bug fix)
  • ♻️ refactor (Code refactoring without changing behavior)
  • 💄 style (UI style changes)
  • 🔨 chore (Build, CI, maintenance)
  • 📝 docs (Documentation updates)

Relevant Issues

resolves #3812

Description

Adds a "Generic OpenAI Compatible" STT provider option, allowing users to use any OpenAI-compatible speech-to-text service (OpenAI Whisper, Groq, Deepgram, self-hosted faster-whisper, etc.) for voice-to-text transcription in the chat prompt input.

What changed:

  • New STT provider selection: Users can now choose between "System native" (browser Web Speech API) and "OpenAI Compatible" in Settings > Audio Preference > Speech-to-text
  • Server-backed transcription: When using the OpenAI Compatible provider, audio is recorded via the browser's MediaRecorder API, sent to a new POST /system/stt endpoint, which proxies the audio to the configured OpenAI-compatible transcription API (/audio/transcriptions)
  • Configurable settings: Base URL, API Key, and Model are configurable via the settings UI
  • Silence detection: Uses Web Audio API's AnalyserNode to detect silence and auto-stop recording after 3.2s (matching native provider behavior)
  • Auto-submit support: Works with the existing "Auto Submit Speech Input" setting
  • CTRL+M shortcut: Works with both providers
  • Decoupled ChatContainer from react-speech-recognition: ChatContainer now uses a custom STOP_STT_EVENT to signal STT stop, making it provider-agnostic
  • Loading spinner on mic button: When using the server-backed provider, clicking the mic shows a spinner while the browser acquires the microphone via getUserMedia. Unlike the native Web Speech API (which manages the mic internally and returns synchronously), the server provider must explicitly request the raw audio stream from the OS — this hardware initialization takes 1-3 seconds depending on the device and browser. The spinner provides visual feedback during this unavoidable delay so users know the app is responding.

Visuals (if applicable)

image

Additional Information

  • The native browser STT provider is completely unchanged — this is purely additive
  • Tested with OpenAI (whisper-1) and Groq (whisper-large-v3) successfully
  • Audio is recorded as audio/webm (browser default) and sent through multer memory storage — no files written to disk

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated (if applicable)
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5268 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 3/25/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `stt-provider-expansion-openai-api-compatible` --- ### 📝 Commits (6) - [`684f144`](https://github.com/Mintplex-Labs/anything-llm/commit/684f1448281477f401bc7feb843a5235f0dd9406) implement generic openai stt provider - [`a7bf476`](https://github.com/Mintplex-Labs/anything-llm/commit/a7bf47610cc00b140fdc98ad8c9218148ab2e4d1) simplify server.jsx - [`f1289ee`](https://github.com/Mintplex-Labs/anything-llm/commit/f1289ee59dc998ba2efbf1c7d4f673f646e3339c) lint and formatting - [`7f1f2bd`](https://github.com/Mintplex-Labs/anything-llm/commit/7f1f2bdc9f611b7e0bfe78bba0789f65760f970a) fix incorrect extension names - [`47e147d`](https://github.com/Mintplex-Labs/anything-llm/commit/47e147d57db07a0ca86ace1354222535b38f3661) cleanup audioContext in endSTTSession - [`afd3b44`](https://github.com/Mintplex-Labs/anything-llm/commit/afd3b44ddbdd5c11e502f3df2d56e7365aedc6ac) add loading state for microphone getUserMedia ### 📊 Changes **13 files changed** (+623 additions, -148 deletions) <details> <summary>View changed files</summary> ➕ `frontend/src/components/SpeechToText/OpenAiGenericOptions/index.jsx` (+70 -0) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SpeechToText/index.jsx` (+19 -135) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SpeechToText/native.jsx` (+146 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SpeechToText/server.jsx` (+208 -0) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/index.jsx` (+4 -13) 📝 `frontend/src/models/system.js` (+14 -0) 📝 `frontend/src/pages/GeneralSettings/AudioPreference/stt.jsx` (+10 -0) 📝 `server/.env.example` (+6 -0) 📝 `server/endpoints/system.js` (+45 -0) 📝 `server/models/systemSettings.js` (+7 -0) ➕ `server/utils/SpeechToText/index.js` (+14 -0) ➕ `server/utils/SpeechToText/openAiGeneric/index.js` (+57 -0) 📝 `server/utils/helpers/updateENV.js` (+23 -0) </details> ### 📄 Description ### Pull Request Type - [x] ✨ feat (New feature) - [ ] 🐛 fix (Bug fix) - [ ] ♻️ refactor (Code refactoring without changing behavior) - [ ] 💄 style (UI style changes) - [ ] 🔨 chore (Build, CI, maintenance) - [ ] 📝 docs (Documentation updates) ### Relevant Issues resolves #3812 ### Description Adds a "Generic OpenAI Compatible" STT provider option, allowing users to use any OpenAI-compatible speech-to-text service (OpenAI Whisper, Groq, Deepgram, self-hosted faster-whisper, etc.) for voice-to-text transcription in the chat prompt input. **What changed:** - **New STT provider selection**: Users can now choose between "System native" (browser Web Speech API) and "OpenAI Compatible" in Settings > Audio Preference > Speech-to-text - **Server-backed transcription**: When using the OpenAI Compatible provider, audio is recorded via the browser's MediaRecorder API, sent to a new `POST /system/stt` endpoint, which proxies the audio to the configured OpenAI-compatible transcription API (`/audio/transcriptions`) - **Configurable settings**: Base URL, API Key, and Model are configurable via the settings UI - **Silence detection**: Uses Web Audio API's AnalyserNode to detect silence and auto-stop recording after 3.2s (matching native provider behavior) - **Auto-submit support**: Works with the existing "Auto Submit Speech Input" setting - **CTRL+M shortcut**: Works with both providers - **Decoupled ChatContainer from react-speech-recognition**: ChatContainer now uses a custom `STOP_STT_EVENT` to signal STT stop, making it provider-agnostic - **Loading spinner on mic button**: When using the server-backed provider, clicking the mic shows a spinner while the browser acquires the microphone via `getUserMedia`. Unlike the native Web Speech API (which manages the mic internally and returns synchronously), the server provider must explicitly request the raw audio stream from the OS — this hardware initialization takes 1-3 seconds depending on the device and browser. The spinner provides visual feedback during this unavoidable delay so users know the app is responding. ### Visuals (if applicable) <img width="1822" height="1186" alt="image" src="https://github.com/user-attachments/assets/d6feae20-255d-4706-95cf-eb27287e96c0" /> ### Additional Information - The native browser STT provider is completely unchanged — this is purely additive - Tested with OpenAI (`whisper-1`) and Groq (`whisper-large-v3`) successfully - Audio is recorded as `audio/webm` (browser default) and sent through multer memory storage — no files written to disk ### Developer Validations - [x] I ran `yarn lint` from the root of the repo & committed changes - [ ] Relevant documentation has been updated (if applicable) - [x] I have tested my code functionality - [ ] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 15:21:10 -04:00
yindo closed this issue 2026-06-05 15:21:10 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5382