React SpeechToText - CustomSpeechRecognizer
Allows you to implement custom speech recognition engines.
import { SpeechToTextTypes } from "devextreme-react/speech-to-text"
Type: SpeechToTextTypes.CustomSpeechRecognizer
If you want to integrate a custom speech recognition engine, set customSpeechRecognizer.enabled to true. When you implement a custom speech recognizer, SpeechToText no longer does the following:
- Listen to user speech.
- Update the component state. Set SpeechToText state manually using the customSpeechRecognizer.isListening property.
- Call the onResult and onError handlers.
enabled
Specifies whether a custom speech recognition engine is implemented.
Type:
Default Value: false
isListening
Indicates whether the custom speech recognition engine is listening.
Type:
Default Value: false
Modify isListening to update the component state:
App.tsx
- import React from 'react';
- import { SpeechToText, CustomSpeechRecognizer, type SpeechToTextTypes } from 'devextreme-react/speech-to-text';
- function handleStartClick(e: SpeechToTextTypes.StartClickEvent): void {
- e.component.option('customSpeechRecognizer.isListening', true);
- }
- function handleStopClick(e: SpeechToTextTypes.StopClickEvent): void {
- e.component.option('customSpeechRecognizer.isListening', false);
- }
- function App(): JSX.Element {
- return (
- <SpeechToText
- onStartClick={handleStartClick}
- onStopClick={handleStopClick}
- >
- <CustomSpeechRecognizer
- enabled={true}
- />
- </SpeechToText>
- );
- }
This property affects the SpeechToText icon (startIcon/stopIcon), text (startText/stopText), and click handler (onStartClick/onStopClick).