|
| 1 | +--- |
| 2 | +title: Overview |
| 3 | +page_title: SpeechToTextButton Overview |
| 4 | +description: Learn about the SpeechToTextButton component, its features, and how to use it in Blazor applications. |
| 5 | +slug: speechtotextbutton-overview |
| 6 | +tags: blazor, speech recognition, button, voice input |
| 7 | +published: true |
| 8 | +position: 1 |
| 9 | +--- |
| 10 | + |
| 11 | +# Blazor SpeechToTextButton Overview |
| 12 | + |
| 13 | +The `SpeechToTextButton` component enables speech recognition in Blazor applications. It provides a button that users can select to start and stop speech recognition. The component converts spoken words into text and emits events with the recognized results. |
| 14 | + |
| 15 | +Use the `SpeechToTextButton` component to add voice input capabilities to forms, search bars, chat interfaces, and other scenarios that require speech-to-text functionality. |
| 16 | + |
| 17 | +## Basic Usage |
| 18 | + |
| 19 | +The following example demonstrates how to add the `SpeechToTextButton` to a Blazor page and handle the recognition result. |
| 20 | + |
| 21 | +**Example of Using the SpeechToTextButton** |
| 22 | + |
| 23 | +<demo metaUrl="client/speechtotextbutton/overview/" height="200"></demo> |
| 24 | + |
| 25 | +## Appearance |
| 26 | + |
| 27 | +You can customize the appearance of the `SpeechToTextButton` by setting parameters such as `Icon`, and `Class`. For more details and examples, refer to [SpeechToTextButton Appearance](slug:speechtotextbutton-appearance). |
| 28 | + |
| 29 | +## Events |
| 30 | + |
| 31 | +The `SpeechToTextButton` component emits several events that you can handle. For more details, refer to [SpeechToTextButton Events](slug:speechtotextbutton-events). |
| 32 | + |
| 33 | +## SpeechToTextButton Parameters |
| 34 | + |
| 35 | +Configure the `SpeechToTextButton` by setting its parameters: |
| 36 | + |
| 37 | +@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout) |
| 38 | + |
| 39 | +| Parameter | Type and Default Value | Description | |
| 40 | +|---------------------|-------------------------------------------------------------|----------------------------------------------------------------------------------------------| |
| 41 | +| `Id` | `string` | Sets the `id` attribute of the button. | |
| 42 | +| `Icon` | `object` | Specifies the icon rendered in the button. | |
| 43 | +| `Title` | `string` | Sets the `title` attribute of the button. | |
| 44 | +| `Enabled` | `bool`<br />(`true`) | Specifies whether the button is enabled. | |
| 45 | +| `TabIndex` | `int`<br />(`0`) | Sets the `tabindex` attribute of the button. | |
| 46 | +| `Lang` | `string`<br />(`browser or system language`) | BCP 47 language tag (for example, `en-US`). | |
| 47 | +| `Continuous` | `bool`<br />(`false`) | Specify whether to return continuous results. | |
| 48 | +| `InterimResults` | `bool`<br />(`false`) | Specify whether to return interim results. | |
| 49 | +| `MaxAlternatives` | `int`<br />(`1`) | The maximum number of recognition alternatives. | |
| 50 | +| `IntegrationMode` | `SpeechToTextButtonIntegrationMode`<br />(`WebSpeech`) | Specify the speech recognition engine or integration mode. | |
| 51 | +| `AriaLabel` | `string` | Sets the `aria-label` attribute of the button. | |
| 52 | +| `AriaLabelledBy` | `string` | Sets the `aria-labelledby` attribute of the button. | |
| 53 | +| `AriaDescribedBy` | `string` | Sets the `aria-describedby` attribute of the button. | |
| 54 | +| `AriaControls` | `string` | Sets the `aria-controls` attribute of the button. | |
| 55 | + |
| 56 | +## SpeechToTextButtton Reference and Methods |
| 57 | + |
| 58 | +The `SpeechToTextButton` component exposes several public methods that you can call from your code: |
| 59 | + |
| 60 | +| Method | Description | |
| 61 | +|----------------|----------------------------------------------------------------------------------------------| |
| 62 | +| `StartAsync` | Start the speech-to-text recognition process. | |
| 63 | +| `StopAsync` | Stop the speech recognition process. | |
| 64 | +| `AbortAsync` | Abort the speech recognition process without returning a result. | |
| 65 | +| `Refresh` | Force the component to re-render. | |
| 66 | + |
| 67 | +**Example of Calling a Method by Reference** |
| 68 | + |
| 69 | +<div class="skip-repl"></div> |
| 70 | +````RAZOR |
| 71 | +<TelerikSpeechToTextButton @ref="speechToTextButtonRef" /> |
| 72 | +
|
| 73 | +@code { |
| 74 | + private async Task StartRecognition() |
| 75 | + { |
| 76 | + await speechToTextButtonRef.StartAsync(); |
| 77 | + } |
| 78 | +} |
| 79 | +```` |
| 80 | + |
| 81 | +## Supported Browsers |
| 82 | + |
| 83 | +The `SpeechToTextButton` component relies on the Web Speech API. For a list of supported browsers, refer to the [Web Speech API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API#browser_compatibility). |
| 84 | + |
| 85 | +## Next Steps |
| 86 | + |
| 87 | +* [Handle SpeechToTextButton Events](slug:speechtotextbutton-events) |
| 88 | +* [SpeechToTextButton Integration](slug:speechtotextbutton-integration) |
| 89 | + |
| 90 | +## See Also |
| 91 | + |
| 92 | +- [SpeechToTextButton Live Demo](https://demos.telerik.com/blazor-ui/speechtotextbutton/overview) |
| 93 | +- [SpeechToTextButton API Reference](/blazor-ui/api/Telerik.Blazor.Components.TelerikSpeechToTextButton) |
| 94 | +- [SpeechToTextButton Events](slug:speechtotextbutton-events) |
| 95 | +- [SpeechToTextButton Appearance](slug:speechtotextbutton-appearance) |
| 96 | +- [SpeechToTextButton Integration](slug:speechtotextbutton-integration) |
0 commit comments