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

Function readTranscript

packages/@react-spectrum/ai/src/useVoiceInput.ts:143–158  ·  view source on GitHub ↗
(event: SpeechRecognitionEvent)

Source from the content-addressed store, hash-verified

141
142/** Accumulates interim vs final transcripts from a recognition result event. */
143const readTranscript = (event: SpeechRecognitionEvent): {interim: string; final: string} => {
144 let interim = '';
145 let final = '';
146 for (let i = event.resultIndex; i < event.results.length; i++) {
147 const result = event.results[i];
148 const alternative = result?.[0];
149 if (result && alternative) {
150 if (result.isFinal) {
151 final += alternative.transcript;
152 } else {
153 interim += alternative.transcript;
154 }
155 }
156 }
157 return {interim, final};
158};
159
160interface RecognizerSetup {
161 recognitionRef: RefObject<SpeechRecognition | null>;

Callers 1

createRecognizerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected