Getting Started with ASP.NET MVC SpeechToText control
21 Jul 20265 minutes to read
This section briefly explains how to include the ASP.NET MVC SpeechToText control in your ASP.NET MVC application using Visual Studio.
Prerequisites
.NET and Visual Studio compatibility
| .NET Version | Visual Studio Version |
|---|---|
| .NET Framework 4.6.2 | Visual Studio 2015 Update 3 or later |
Browser support
| Browser | Versions |
|---|---|
| Google Chrome, including Android & iOS | Latest Version |
| Mozilla Firefox | Latest Version |
| Microsoft Edge | Latest Version |
| Apple Safari, including iOS | Latest Version |
| Opera | Latest Version |
| Microsoft Internet Explorer | 11 |
Create ASP.NET MVC application with HTML helper
Install ASP.NET MVC package in the application
To add ASP.NET MVC controls in the application, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search for Syncfusion.EJ2.MVC5 and then install it.
Install-Package Syncfusion.EJ2.MVC5 -Version 34.1.29NOTE
Syncfusion® ASP.NET MVC controls are available in nuget.org. Refer to NuGet packages topic to learn more about installing NuGet packages in various OS environments. The Syncfusion.EJ2.MVC5 NuGet package has dependencies, Newtonsoft.Json for JSON serialization and Syncfusion.Licensing for validating Syncfusion® license key.
Add namespace
Add Syncfusion.EJ2 namespace reference in Web.config under Views folder.
<namespaces>
<add namespace="Syncfusion.EJ2"/>
</namespaces>
Add stylesheet and script resources
Here, the theme and script are referred using CDN inside the <head> of the ~/Views/Shared/_Layout.cshtml file as follows,
<head>
...
<!-- Syncfusion ASP.NET MVC controls styles -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/34.1.29/fluent.css" />
<!-- Syncfusion ASP.NET MVC controls scripts -->
<script src="https://cdn.syncfusion.com/ej2/34.1.29/dist/ej2.min.js"></script>
</head>NOTE
Check out the Themes topic to learn different ways (CDN, NPM package, and CRG) to refer styles in ASP.NET MVC application, and to have the expected appearance for Syncfusion® ASP.NET MVC controls. Check out the Adding Script Reference topic to learn different approaches for adding script references in your ASP.NET MVC application.
Register Syncfusion® script manager
Also, register the script manager EJS().ScriptManager() at the end of <body> in the ~/Views/Shared/_Layout.cshtml file as follows.
<body>
...
<!-- Syncfusion ASP.NET MVC Script Manager -->
@Html.EJS().ScriptManager()
</body>Add ASP.NET MVC SpeechToText control
Now, add the Syncfusion® ASP.NET MVC SpeechToText control in ~/Views/Home/Index.cshtml page.
@using Syncfusion.EJ2.Inputs
<div id='speechtotext-container'>
@Html.EJS().SpeechToText("speech-to-text").TranscriptChanged("onTranscriptChanged").Render()
@Html.EJS().TextArea("output-textarea").Rows(5).Cols(50).Value("").ResizeMode(Resize.None).Placeholder("Transcribed text will be shown here...").Render()
</div>
<script>
function onTranscriptChanged(args) {
var textareaObj = ej.base.getComponent(document.getElementById("output-textarea"), "textarea");
textareaObj.value = args.transcript;
}
</script>
<style>
#speechtotext-container {
gap: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
</style>Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to run the app. Then, the Syncfusion® ASP.NET MVC SpeechToText control will be rendered in the default web browser.

Adding button content
You can use the Content property to display the start listening text and StopContent to display the stop listening text by using the ButtonSettings property.
@using Syncfusion.EJ2.Inputs
<div id='speechtotext-container'>
@Html.EJS().SpeechToText("speech-to-text").TranscriptChanged("onTranscriptChanged").ButtonSettings(new SpeechToTextButtonSettings { Content = "Start Listening", StopContent = "Stop Listening" }).Render()
@Html.EJS().TextArea("output-textarea").Rows(5).Cols(50).Value("").ResizeMode(Resize.None).Placeholder("Transcribed text will be shown here...").Render()
</div>
<script>
function onTranscriptChanged(args) {
var textareaObj = ej.base.getComponent(document.getElementById("output-textarea"), "textarea");
textareaObj.value = args.transcript;
}
</script>
<style>
#speechtotext-container {
gap: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
</style>
