Repository navigation
Conversation
WalkthroughThis PR updates the audio captions component to determine available transcription languages by querying browser speech recognition support instead of speech synthesis voices. The service module adds two new functions: Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/captions/component.tsx (1)
150-157: ⚡ Quick win
voicesListstate and itsuseEffectare vestigial — consider removing them
getAvailableTranscriptionLanguages()is synchronous and module-level–cached, sovoicesis stable across renders. TheuseEffectonly copies it once intovoicesList, butvoices || voicesListalways prefersvoiceswhen it is non-null (including when it is an empty array[], which is truthy). ThevoicesListfallback is effectively unreachable dead code.Once the critical async fix is applied, the component will need to manage async state explicitly anyway — at that point this pattern can be replaced cleanly with a single
useState<string[] | null>(null)initialized via auseEffect+await.Also applies to: 173-173
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/captions/component.tsx` around lines 150 - 157, Remove the dead state and effect: delete the voicesList useState and the useEffect that copies getAvailableTranscriptionLanguages() into it, and replace uses of voicesList with the direct voices variable returned by getAvailableTranscriptionLanguages(); keep getAvailableTranscriptionLanguages() as the single source of truth now and later refactor to a useState<string[] | null> + async useEffect when the async loading change is implemented.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/service.ts`:
- Around line 76-90: The isSpeechRecognitionLanguageSupported function must be
made async and call SR.available with the correct signature and await its
Promise: call SR.available({ langs: [lang], processLocally: false }) (or omit
processLocally if not needed), await the returned AvailabilityStatus and return
a boolean (e.g. status === "available"); then update the caller that builds
cachedTranscriptionLanguages to handle the async results (e.g. map langs to
Promises, await Promise.all, filter by the resolved booleans, or move the
filtering into a useEffect/state flow) so the language filter is no longer a
no-op; refer to isSpeechRecognitionLanguageSupported and the
cachedTranscriptionLanguages producer in your changes.
---
Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/captions/component.tsx`:
- Around line 150-157: Remove the dead state and effect: delete the voicesList
useState and the useEffect that copies getAvailableTranscriptionLanguages() into
it, and replace uses of voicesList with the direct voices variable returned by
getAvailableTranscriptionLanguages(); keep getAvailableTranscriptionLanguages()
as the single source of truth now and later refactor to a useState<string[] |
null> + async useEffect when the async loading change is implemented.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 256b1b10-a4dc-4e79-b1f9-e8202be0d3c7
📒 Files selected for processing (2)
bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/captions/component.tsxbigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/service.ts
| const isSpeechRecognitionLanguageSupported = (lang: string): boolean => { | ||
| try { | ||
| // @ts-ignore - SR types is not yet in the TS types | ||
| const SR = window.SpeechRecognition || window.webkitSpeechRecognition; | ||
| if (!SR) return false; | ||
| if (typeof SR.available === 'function') { | ||
| return SR.available(lang); | ||
| } | ||
| // If SpeechRecognition.available() is not implemented in this browser, | ||
| // fall back to assuming all languages are supported. | ||
| return true; | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, locate and examine the service.ts file
find . -name "service.ts" -path "*/audio-captions/*" | head -5Repository: bigbluebutton/bigbluebutton
Length of output: 258
🏁 Script executed:
# Get more context around the function
fd service.ts -path "*/audio-captions/*" -x wc -l {}Repository: bigbluebutton/bigbluebutton
Length of output: 240
🏁 Script executed:
# Find the exact file path
fd -i service.ts | grep -i "audio.*captions"Repository: bigbluebutton/bigbluebutton
Length of output: 254
🏁 Script executed:
# Read the service.ts file to verify the code and context
cat -n ./bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/service.tsRepository: bigbluebutton/bigbluebutton
Length of output: 6230
🏁 Script executed:
# Check the entire file size first
wc -l ./bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/service.tsRepository: bigbluebutton/bigbluebutton
Length of output: 165
🏁 Script executed:
# Check if there are any tests for this function
find . -name "*.test.*" -o -name "*.spec.*" | xargs grep -l "isSpeechRecognitionLanguageSupported" 2>/dev/null || echo "No tests found"Repository: bigbluebutton/bigbluebutton
Length of output: 86
🏁 Script executed:
# Search for any comments or documentation about SpeechRecognition.available
rg "SpeechRecognition\.available" -B 3 -A 3Repository: bigbluebutton/bigbluebutton
Length of output: 2854
🏁 Script executed:
# Look for any usage of SR.available in the codebase
rg "\.available\(" -B 2 -A 2 --type ts --type js | head -50Repository: bigbluebutton/bigbluebutton
Length of output: 2359
🌐 Web query:
Web Speech API SpeechRecognition.available() method specification
💡 Result:
The SpeechRecognition.available is a static method of the Web Speech API that checks whether specified languages are available for speech recognition. It returns a Promise resolving to an AvailabilityStatus enum value: 'available' (all languages supported, on-device if processLocally:true or on-device/remote if false), 'downloading' (language pack downloading, on-device only), 'downloadable' (supported but not installed, on-device only), or 'unavailable' (not supported for at least one language).[1][2][3] Syntax: SpeechRecognition.available(options), where options is an object with: - langs: array of BCP 47 language tags (e.g., ['en-US']; empty array resolves to 'unavailable') - processLocally: boolean (default false; true checks only on-device)[1][2] Access is controlled by the 'on-device-speech-recognition' Permissions-Policy; blocked policies cause failure.[1][2] This method is not in the original 2012 W3C draft[4] but appears in recent drafts (e.g., 2025)[3] and MDN docs (updated 2025).[2][5][6]
Citations:
- 1: https://developer.mozilla.org/docs/Web/API/SpeechRecognition/available_static
- 2: https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/available_static
- 3: https://webaudio.github.io/web-speech-api/
- 4: https://dvcs.w3.org/hg/speech-api/raw-file/tip/webspeechapi
- 5: https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition
- 6: https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/install_static
🌐 Web query:
SpeechRecognition.available() Promise AvailabilityStatus MDN Web Speech API
💡 Result:
SpeechRecognition.available is a static method in the Web Speech API that returns a Promise resolving to an AvailabilityStatus enum value indicating whether specified languages are available for speech recognition [1][2]. It checks availability for on-device or remote (default) recognition based on options [1][2].
Citations:
- 1: https://developer.mozilla.org/docs/Web/API/SpeechRecognition/available_static
- 2: https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/available_static
🌐 Web query:
SpeechRecognition available() static method signature parameters
💡 Result:
The SpeechRecognition.available static method has the following signature: available(options) Parameters: - options: An object with: - langs: Array of BCP 47 language tags (strings) to check for availability. Empty array resolves to 'unavailable'.[1][2][3] - processLocally (optional, default false): Boolean; true checks only on-device recognition, false checks on-device or remote.[1][2][3] It returns a Promise resolving to an AvailabilityStatus enum: 'available', 'downloading', 'downloadable', or 'unavailable'.[1][4] This is from the Web Speech API, experimental with limited browser support.[1][3]
Citations:
- 1: https://developer.mozilla.org/docs/Web/API/SpeechRecognition/available_static
- 2: https://github.com/mdn/content/blob/main/files/en-us/web/api/speechrecognition/available_static/index.md
- 3: https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/available_static
- 4: https://webaudio.github.io/web-speech-api/
SR.available() is called with the wrong signature and returns a Promise that is always truthy — the language filter is a complete no-op
Per the Web Speech API spec, SpeechRecognition.available() is an async method that returns a Promise resolving to an AvailabilityStatus enum ("available", "downloading", "downloadable", or "unavailable"). The correct signature is SpeechRecognition.available({ langs: ["en-US"], processLocally?: boolean }).
The code has two critical problems:
- Wrong argument type:
SR.available(lang)passes a plain string; the spec requires{ langs: string[] }. - Unhandled Promise: The function returns a
Promiseobject directly without awaiting it. Since a Promise is always truthy,.filter(isSpeechRecognitionLanguageSupported)includes every language regardless of support — the entire filtering logic is a no-op.
Result: In browsers implementing the Web Speech API, cachedTranscriptionLanguages always equals unique(LANGUAGES), defeating the stated goal of filtering by language support.
The fix requires making isSpeechRecognitionLanguageSupported async and updating the caller to handle the Promise:
🐛 Proposed fix
-const isSpeechRecognitionLanguageSupported = (lang: string): boolean => {
+const isSpeechRecognitionLanguageSupported = async (lang: string): Promise<boolean> => {
try {
// `@ts-ignore` - SR types is not yet in the TS types
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
if (!SR) return false;
if (typeof SR.available === 'function') {
- return SR.available(lang);
+ const result = await SR.available({ langs: [lang] });
+ return result !== 'unavailable';
}
- // If SpeechRecognition.available() is not implemented in this browser,
- // fall back to assuming all languages are supported.
+ // Browser supports SR but not the available() API; assume all languages work.
return true;
} catch (e) {
return false;
}
};
-export const getAvailableTranscriptionLanguages = (): string[] | null => {
+export const getAvailableTranscriptionLanguages = async (): Promise<string[] | null> => {
const LANGUAGES: string[] = window.meetingClientSettings.public.app.audioCaptions.language.available;
if (!isWebSpeechApi()) return LANGUAGES;
if (!hasSpeechRecognitionSupport()) return null;
if (cachedTranscriptionLanguages !== null) return cachedTranscriptionLanguages;
- cachedTranscriptionLanguages = unique(LANGUAGES).filter(isSpeechRecognitionLanguageSupported);
+ const results = await Promise.all(unique(LANGUAGES).map(isSpeechRecognitionLanguageSupported));
+ cachedTranscriptionLanguages = unique(LANGUAGES).filter((_, i) => results[i]);
return cachedTranscriptionLanguages;
};The calling component will need to handle the async result (e.g., via useEffect + state, or a custom hook).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-captions/service.ts`
around lines 76 - 90, The isSpeechRecognitionLanguageSupported function must be
made async and call SR.available with the correct signature and await its
Promise: call SR.available({ langs: [lang], processLocally: false }) (or omit
processLocally if not needed), await the returned AvailabilityStatus and return
a boolean (e.g. status === "available"); then update the caller that builds
cachedTranscriptionLanguages to handle the async results (e.g. map langs to
Promises, await Promise.all, filter by the resolved booleans, or move the
filtering into a useEffect/state flow) so the language filter is no longer a
no-op; refer to isSpeechRecognitionLanguageSupported and the
cachedTranscriptionLanguages producer in your changes.
🚨 Automated tests failed |
|
This is actually more complicated than I thought here's an issue to track this problem: #25068 |




The old getSpeechVoices method was used for the purpose of filtering supported languages for the browser SpeechRecognition API. This was the wrong API to call and in some cases like for example Catalan it would result in the language being configured in the
app.audioCaptions.language.availablearray but no actually showing in the dropdow list.This new code attempts to call the correct API if it's present in the browser and now properly let's us configure and select all valid languages for a given SpeechRecognition API instance.