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

Function readTranscript

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

Source from the content-addressed store, hash-verified

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

Callers 1

createRecognizerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected