MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getRecognitionCtor

Function getRecognitionCtor

packages/@react-spectrum/ai/src/useVoiceInput.ts:67–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66/** Resolves the recognizer constructor, applying the Chromium brand allowlist. */
67const getRecognitionCtor = (): SpeechRecognitionConstructor | null => {
68 if (typeof window === 'undefined') {
69 return null;
70 }
71 const ctor = window.SpeechRecognition ?? window.webkitSpeechRecognition ?? null;
72 if (!ctor) {
73 return null;
74 }
75 const brands = navigator.userAgentData?.brands;
76 if (brands && !brands.some(b => VOICE_INPUT_CHROMIUM_BROWSERS.has(b.brand))) {
77 return null;
78 }
79 return ctor;
80};
81
82/** SpeechRecognition requires a secure context (HTTPS / localhost). */
83const isSecureVoiceContext = (): boolean =>

Callers 1

useVoiceInputFunction · 0.85

Calls 1

hasMethod · 0.65

Tested by

no test coverage detected