Contents
- Start listening
- Stop listening
Having trouble getting help?
Contact Support
Contact Support
Methods in ASP.NET CORE SpeechToText control
28 Apr 20252 minutes to read
Start listening
You can use the startListening
public method to initiate the speech recognition and begins the conversion of the speech to text.
Stop listening
You can use the stopListening
public method to stop capturing your speech and ends the speech recognition.
Below sample demonstrates the SpeechToText control configured with above methods.
@using Syncfusion.EJ2.Inputs
<div id='speechtotext-container'>
<div class="actions">
<button id="startListening" class="e-btn">Start Listening</button>
<button id="stopListening" class="e-btn">Stop Listening</button>
</div>
<ejs-speechtotext id="speech-to-text" created="onCreated" transcriptChanged="onTranscriptChanged"></ejs-speechtotext>
<ejs-textarea id="output-textarea" rows="5" cols="50" value="" resizeMode="None" placeholder="Transcribed text will be shown here..."></ejs-textarea>
</div>
<script>
var speechToTextObj;
function onCreated() {
speechToTextObj = ej.base.getComponent(document.getElementById("speech-to-text"), "speech-to-text");
}
function onTranscriptChanged(args) {
var textareaObj = ej.base.getComponent(document.getElementById("output-textarea"), "textarea");
textareaObj.value = args.transcript;
}
document.getElementById("startListening").addEventListener('click', function () {
speechToTextObj.startListening();
});
document.getElementById("stopListening").addEventListener('click', function () {
speechToTextObj.stopListening();
});
</script>
<style>
#speechtotext-container {
gap: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
</style>
public ActionResult Methods()
{
return View();
}