Angular SpeechToText Properties
A configuration object for the SpeechToText UI component.
See Also
accessKey
Specifies the shortcut key that sets focus on the UI component.
The value of this property will be passed to the accesskey attribute of the HTML element that underlies the UI component.
activeStateEnabled
Specifies whether the UI component changes its visual state as a result of user interaction.
The UI component switches to the active state when users press down the primary mouse button. When this property is set to true, the CSS rules for the active state apply. You can change these rules to customize the component.
Use this property when you display the component on a platform whose guidelines include the active state change for UI components.
customSpeechRecognizer
Allows you to implement custom speech recognition engines.
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:
- Listens to user speech.
- Updates the component state. Set the SpeechToText state using the customSpeechRecognizer.isListening property.
- Calls the onResult and onError handlers.
disabled
Specifies whether the UI component responds to user interaction.
elementAttr
Specifies the global attributes to be attached to the UI component's container element.
jQuery
$(function(){
$("#speechToTextContainer").dxSpeechToText({
// ...
elementAttr: {
id: "elementId",
class: "class-name"
}
});
});Angular
<dx-speech-to-text ...
[elementAttr]="{ id: 'elementId', class: 'class-name' }">
</dx-speech-to-text>
import { DxSpeechToTextModule } from "devextreme-angular";
// ...
export class AppComponent {
// ...
}
@NgModule({
imports: [
// ...
DxSpeechToTextModule
],
// ...
})Vue
<template>
<DxSpeechToText ...
:element-attr="speechToTextAttributes">
</DxSpeechToText>
</template>
<script>
import DxSpeechToText from 'devextreme-vue/speech-to-text';
export default {
components: {
DxSpeechToText
},
data() {
return {
speechToTextAttributes: {
id: 'elementId',
class: 'class-name'
}
}
}
}
</script>React
import React from 'react';
import SpeechToText from 'devextreme-react/speech-to-text';
class App extends React.Component {
speechToTextAttributes = {
id: 'elementId',
class: 'class-name'
}
render() {
return (
<SpeechToText ...
elementAttr={this.speechToTextAttributes}>
</SpeechToText>
);
}
}
export default App;focusStateEnabled
Specifies whether the UI component can be focused using keyboard navigation.
height
Specifies the UI component's height.
This property accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px","20vh","80%","inherit".
hint
Specifies text for a hint that appears when a user pauses on the UI component.
hoverStateEnabled
Specifies whether the UI component changes its state when a user pauses on it.
onContentReady
A function that is executed when the UI component is rendered or repainted.
Information about the event.
| Name | Type | Description |
|---|---|---|
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
| component | SpeechToText |
The UI component's instance. |
onDisposing
A function that is executed before the UI component is disposed of.
Information about the event.
| Name | Type | Description |
|---|---|---|
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
| component | SpeechToText |
The UI component's instance. |
onEnd
A function that is executed when the Web Speech API finishes transcription and SpeechToText switches to the initial component state.
Information about the event.
| Name | Type | Description |
|---|---|---|
| component | SpeechToText |
The UI component's instance. |
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onError
A function that is executed when the Web Speech API encounters an error.
Information about the event.
| Name | Type | Description |
|---|---|---|
| component | SpeechToText |
The UI component's instance. |
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
The following code snippet demonstrates how to implement the notify() utility method to display a Web Speech API error in the onError handler:
jQuery
$('#speech-to-text').dxSpeechToText({
onError(e) {
DevExpress.ui.notify(`Web Speech API encountered an error: ${e.event.error}`);
}
})Angular
<dx-speech-to-text
(onError)="handleError($event)"
></dx-speech-to-text>
import { DxSpeechToTextComponent, type DxSpeechToTextTypes } from 'devextreme-angular/ui/speech-to-text';
import notify from 'devextreme/ui/notify';
// ...
export class AppComponent {
handleError(e: DxSpeechToTextTypes.ErrorEvent) {
notify(`Web Speech API encountered an error: ${e.event.error}`);
}
}Vue
<template>
<DxSpeechToText
@error="handleError"
/>
</template>
<script setup lang="ts">
import { DxSpeechToText, type DxSpeechToTextTypes } from 'devextreme-vue/speech-to-text';
import notify from 'devextreme/ui/notify';
function handleError(e: DxSpeechToTextTypes.ResultEvent) {
notify(`Web Speech API encountered an error: ${e.event.error}`);
}
</script>React
import React from 'react';
import { SpeechToText, type SpeechToTextTypes } from 'devextreme-react/speech-to-text';
import notify from 'devextreme/ui/notify';
function handleError(e: DxSpeechToTextTypes.ResultEvent): void {
notify(`Web Speech API encountered an error: ${e.event.error}`);
}
function App(): JSX.Element {
return (
<SpeechToText
onError={handleError}
/>
);
}onInitialized
A function used in JavaScript frameworks to save the UI component instance.
Information about the event.
| Name | Type | Description |
|---|---|---|
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
| component | SpeechToText |
The UI component's instance. |
Angular
<dx-speech-to-text ...
(onInitialized)="saveInstance($event)">
</dx-speech-to-text>
import { Component } from "@angular/core";
import SpeechToText from "devextreme/ui/data_grid";
// ...
export class AppComponent {
speechToTextInstance: SpeechToText;
saveInstance (e) {
this.speechToTextInstance = e.component;
}
}Vue
<template>
<div>
<DxSpeechToText ...
@initialized="saveInstance">
</DxSpeechToText>
</div>
</template>
<script>
import DxSpeechToText from 'devextreme-vue/speech-to-text';
export default {
components: {
DxSpeechToText
},
data: function() {
return {
speechToTextInstance: null
};
},
methods: {
saveInstance: function(e) {
this.speechToTextInstance = e.component;
}
}
};
</script>
<template>
<div>
<DxSpeechToText ...
@initialized="saveInstance">
</DxSpeechToText>
</div>
</template>
<script setup>
import DxSpeechToText from 'devextreme-vue/speech-to-text';
let speechToTextInstance = null;
const saveInstance = (e) => {
speechToTextInstance = e.component;
}
</script>React
import SpeechToText from 'devextreme-react/speech-to-text';
class App extends React.Component {
constructor(props) {
super(props);
this.saveInstance = this.saveInstance.bind(this);
}
saveInstance(e) {
this.speechToTextInstance = e.component;
}
render() {
return (
<div>
<SpeechToText onInitialized={this.saveInstance} />
</div>
);
}
}See Also
onOptionChanged
A function that is executed after a UI component property is changed.
Information about the event.
| Name | Type | Description |
|---|---|---|
| value | any |
The modified property's new value. |
| previousValue | any |
The modified property's previous value. |
| name |
The modified property. For nested properties, returns the root-level property. |
|
| fullName |
The path to the modified property that includes all parent properties. |
|
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
| component | SpeechToText |
The UI component's instance. |
The following code snippet demonstrates how to subscribe to component property changes:
jQuery
$(function() {
$("#speechToTextContainer").dxSpeechToText({
// ...
onOptionChanged: function(e) {
if(e.name === "changedProperty") {
// handle the property change here
}
}
});
});Angular
<dx-speech-to-text ...
(onOptionChanged)="handlePropertyChange($event)">
</dx-speech-to-text>
import { Component } from '@angular/core';
import { type DxSpeechToTextTypes } from 'devextreme-angular/ui/speech-to-text';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
// ...
handlePropertyChange(e: DxSpeechToTextTypes.OptionChangedEvent) {
if(e.name === "changedProperty") {
// handle the property change here
}
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DxSpeechToTextModule } from 'devextreme-angular/ui/speech-to-text';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DxSpeechToTextModule
],
providers: [ ],
bootstrap: [AppComponent]
})
export class AppModule { } Vue
<template>
<DxSpeechToText ...
@option-changed="handlePropertyChange"
/>
</template>
<script>
import 'devextreme/dist/css/dx.fluent.blue.light.css';
import { DxSpeechToText, type DxSpeechToTextTypes } from 'devextreme-vue/speech-to-text';
function handlePropertyChange: function(e: DxSpeechToTextTypes.OptionChangedEvent) {
if(e.name === "changedProperty") {
// handle the property change here
}
}
</script>React
import React from 'react';
import 'devextreme/dist/css/dx.fluent.blue.light.css';
import { SpeechToText, type SpeechToTextTypes } from 'devextreme-react/speech-to-text';
function handlePropertyChange(e: SpeechToTextTypes.OptionChangedEvent) {
if(e.name === "changedProperty") {
// handle the property change here
}
}
export default function App() {
return (
<SpeechToText ...
onOptionChanged={handlePropertyChange}
/>
);
} onResult
A function that is executed when the Web Speech API returns a result.
Information about the event.
| Name | Type | Description |
|---|---|---|
| component | SpeechToText |
The UI component's instance. |
| element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
The following code snippet demonstrates how to extract transcribed text in the onResult handler:
jQuery
$('#speech-to-text').dxSpeechToText({
onResult(e) {
const resultText = Object.values(e.event.results)
.map((resultItem) => resultItem[0].transcript)
.join(" ");
}
})Angular
<dx-speech-to-text
(onResult)="handleResult($event)"
></dx-speech-to-text>
import { DxSpeechToTextComponent, type DxSpeechToTextTypes } from 'devextreme-angular/ui/speech-to-text';
// ...
export class AppComponent {
handleResult(e: DxSpeechToTextTypes.ResultEvent) {
const resultText = Object.values(e.event.results)
.map((resultItem) => resultItem[0].transcript)
.join(" ");
}
}Vue
<template>
<DxSpeechToText
@result="handleResult"
/>
</template>
<script setup lang="ts">
import { DxSpeechToText, type DxSpeechToTextTypes } from 'devextreme-vue/speech-to-text';
function handleResult(e: DxSpeechToTextTypes.ResultEvent) {
const resultText = Object.values(e.event.results)
.map((resultItem) => resultItem[0].transcript)
.join(" ");
}
</script>React
import React from 'react';
import { SpeechToText, type SpeechToTextTypes } from 'devextreme-react/speech-to-text';
function handleResult(e: DxSpeechToTextTypes.ResultEvent): void {
const resultText = Object.values(e.event.results)
.map((resultItem) => resultItem[0].transcript)
.join(" ");
}
function App(): JSX.Element {
return (
<SpeechToText
onResult={handleResult}
/>
);
}onStartClick
A function that is executed when the SpeechToText button is clicked or tapped in the initial component state.
Information about the event.
| Name | Type | Description |
|---|---|---|
| component | SpeechToText |
The UI component's instance. |
| element |
The UI component's container. |
|
| event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
onStopClick
A function that is executed when the SpeechToText button is clicked or tapped in the "listening" component state.
Information about the event.
| Name | Type | Description |
|---|---|---|
| component | SpeechToText |
The UI component's instance. |
| element |
The UI component's container. |
|
| event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
rtlEnabled
Switches the UI component to a right-to-left representation.
When this property is set to true, the UI component text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.
DevExpress.config({
rtlEnabled: true
});speechRecognitionConfig
Configures the Web Speech API (SpeechRecognition properties).
This configuration object allows you to customize SpeechToText functionality.
startIcon
The SpeechToText button icon in the initial component state.
stopIcon
The SpeechToText button icon in the "listening" component state.
stylingMode
Specifies SpeechToText button styling.
The following image demonstrates available SpeechToText types (arranged vertically) and styling modes (arranged horizontally):

tabIndex
Specifies the number of the element when the Tab key is used for navigating.
The value of this property will be passed to the tabindex attribute of the HTML element that underlies the UI component.
type
Specifies the SpeechToText button type.
The following image demonstrates available SpeechToText types (arranged vertically) and styling modes (arranged horizontally):

You can also create a SpeechToText type and define custom CSS rules:
jQuery
$(function() {
$("#speech-to-text").dxSpeechToText({
// ...
type: "warning"
});
});
.dx-button.dx-button-warning {
background-color: #ffc107;
}Angular
<dx-speech-to-text ...
type="warning"
></dx-speech-to-text>
.dx-button.dx-button-warning {
background-color: #ffc107;
}Vue
<template>
<DxSpeechToText ...
type="warning"
/>
</template>
<script>
// ...
</script>
<style>
.dx-button.dx-button-warning {
background-color: #ffc107;
}
</style>React
function App() {
return (
<SpeechToText ...
type="warning"
/>
);
};
.dx-button.dx-button-warning {
background-color: #ffc107;
}width
Specifies the UI component's width.
This property accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px","20vw","80%","auto","inherit".
If you have technical questions, please create a support ticket in the DevExpress Support Center.