# ASP.NET Core SpeechToTextButton Overview

The Telerik UI SpeechToTextButton TagHelper and HtmlHelper for ASP.NET Core are server-side wrappers for the Kendo UI SpeechToTextButton widget.

The SpeechToTextButton is an interactive UI component that converts spoken words into written text using the browser's built-in speech recognition capabilities. This powerful tool enhances user experience by providing an alternative input method valuable for accessibility, mobile applications, and scenarios where hands-free interaction is preferred. Users click the button to activate voice recording, speak naturally, and watch their words automatically transcribed into editable text. The component is suitable for form filling, content creation, search functionality, and any application requiring efficient voice-to-text conversion.

* [Demo page for the SpeechToTextButton](https://demos.telerik.com/aspnet-core/speechtotextbutton)

## Initializing the SpeechToTextButton

The following example demonstrates how to define the SpeechToTextButton component.

```Razor HtmlHelper
@(Html.Kendo().SpeechToTextButton()
    .Name("speechButton")
    .IntegrationMode(IntegrationMode.WebSpeech)
    .Icon("microphone")
    .StopIcon("stop")
)
```

```Razor TagHelper
@addTagHelper *, Kendo.Mvc

<kendo-speechtotextbutton name="speechButton"
    integration-mode="IntegrationMode.WebSpeech"
    icon="microphone"
    stop-icon="stop">
</kendo-speechtotextbutton>
```

## Basic Configuration

Usually, the SpeechToTextButton is integrated with other input UI components, such as [TextBox](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/textbox/overview), [TextArea](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/textarea/overview), or [NumericTextBox](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/numerictextbox/overview), to display the converted speech-to-text results, enabling direct voice-to-text input functionality within the editors.

Handle the `Result` client-side event to update an input field with the recognized text. For example, you can enable users to fill out a feedback form by speaking instead of typing. When the user clicks the button, the component captures the speech and updates the value of the editor with the recognized text.

The following example demonstrates a basic integration of the SpeechToTextButton into a TextBox component. The SpeechToTextButton is displayed in the suffix adornment of the TextBox using the [Template](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/template/overview) component.

```Razor HtmlHelper
@(Html.Kendo().TextBox()
    .Name("txtBox")
    .SuffixOptions(suffix =>
    {
        suffix.Template(Html.Kendo().Template()
        .AddHtml("<div class='description k-ml-xs'>Click the mic to speak</div>")
        .AddComponent(btn => btn
        .SpeechToTextButton()
        .Name("speechButton")
        .FillMode(ButtonFillMode.Flat)
        .Events(ev => ev.Result("onResult"))
        ));
    })
)
```

```Razor TagHelper
@addTagHelper *, Kendo.Mvc

<kendo-textbox name="txtBox">
    <suffix-options>
        <suffix-template>
            <div class='description k-ml-xs'>Click the mic to speak</div>
            <kendo-speechtotextbutton name="speechButton" on-result="onResult"
                fill-mode="ButtonFillMode.Flat">
            </kendo-speechtotextbutton
        </suffix-template>
    </suffix-options>
</kendo-textbox>
```

```JS Scripts
<script>
    function onResult(e) {
        var transcript = e.alternatives[0].transcript; // Access the array of alternative transcripts. 
        $("#txtBox").data("kendoTextBox").value(`${transcript}`);
    }
</script>
```

## Functionality and Features

* [Appearance](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/speechtotextbutton/appearance)—You can control the appearance of the SpeechToTextButton by configuring its styling options.
* [Events](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/speechtotextbutton/events)—The component emits a variety of events that allow you to implement custom functionality.
* [Accessibility](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/speechtotextbutton/accessibility/overview)—The SpeechToTextButton is accessible for screen readers, supports WAI-ARIA attributes, and delivers [keyboard shortcuts](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/speechtotextbutton/accessibility/keyboard-navigation) for faster navigation.

## Button States

The SpeechToTextButton component operates in three distinct states that reflect the current status of the speech recognition process:

* Inactive State—The state before speech recognition begins. The default button's icon is `microphone`.
* Active State (listening)—Indicates that speech recognition is currently in progress. The button's icon changes to the default `stop` icon.
* Error State—Triggers when speech recognition encounters an error or when the Web Speech API is not supported by the browser.

## Browser Support

By default, the SpeechToTextButton component relies on the Web Speech API to perform speech recognition. 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).

> important The [Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API) requires a secure context (HTTPS) in most browsers. Ensure your application is served over HTTPS for optimal functionality.

## Next Steps

* [Getting Started with the SpeechToTextButton](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/speechtotextbutton/getting-started)
* [Basic Usage of the SpeechToTextButton for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/speechtotextbutton)

## See Also

* [Using the API of the SpeechToTextButton (Demo)](https://demos.telerik.com/aspnet-core/speechtotextbutton/api)

* [Server-Side API of the SpeechToTextButton](https://www.telerik.com/aspnet-core-ui/documentation/api/speechtotextbutton)

* [Server-Side API of the SpeechToTextButton TagHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/taghelpers/speechtotextbutton)

* [Knowledge Base Section](https://www.telerik.com/aspnet-core-ui/documentation/knowledge-base)
