Globalization in ASP.NET CORE SpeechToText control

28 Apr 20256 minutes to read

Localization

The SpeechToText can be localized to any culture by defining the text in the corresponding culture. The default locale of the SpeechToText is en-US (English). The following table represents the default text of the SpeechToText in en-US culture.

KEY Text
abortedError Speech recognition was aborted.
audioCaptureError No microphone detected. Ensure your microphone is connected.
defaultError An unknown error occurred.
networkError Network error occurred. Check your internet connection.
noSpeechError No speech detected. Please speak into the microphone.
notAllowedError Microphone access denied. Allow microphone permissions.
serviceNotAllowedError Speech recognition service is not allowed in this context.
unsupportedBrowserError The browser does not support the SpeechRecognition API.
startAriaLabel Press to start speaking and transcribe your words
stopAriaLabel Press to stop speaking and end transcription
startTooltipText Start listening
stopTooltipText Stop listening
@using Syncfusion.EJ2.Inputs

<div id='speechtotext-container'>
    <ejs-speechtotext id="speech-to-text" locale="de" 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>
    ej.base.L10n.load({
        'de': {
            "speech-to-text": {
                "abortedError": "Die Spracherkennung wurde abgebrochen.",
                "audioCaptureError": "Kein Mikrofon erkannt. Stellen Sie sicher, dass Ihr Mikrofon angeschlossen ist.",
                "defaultError": "Ein unbekannter Fehler ist aufgetreten.",
                "networkError": "Netzwerkfehler aufgetreten. Überprüfen Sie Ihre Internetverbindung.",
                "noSpeechError": "Keine Sprache erkannt. Bitte sprechen Sie in das Mikrofon.",
                "notAllowedError": "Mikrofonzugriff verweigert. Erlauben Sie Mikrofonberechtigungen.",
                "serviceNotAllowedError": "Der Spracherkennungsdienst ist in diesem Kontext nicht erlaubt.",
                "unsupportedBrowserError": "Der Browser unterstützt die SpeechRecognition API nicht.",
                "startAriaLabel": "Drücken Sie, um zu sprechen und Ihre Worte zu transkribieren",
                "stopAriaLabel": "Drücken Sie, um das Sprechen zu beenden und die Transkription zu stoppen",
                "startTooltipText": "Zuhören starten",
                "stopTooltipText": "Zuhören beenden"
            }
        }
    });
    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>
public ActionResult Localization()
{
    return View();
}

Localization

RTL

RTL provides an option to switch the text direction and layout of the SpeechToText control from right to left by setting the enableRtl property to true.

@using Syncfusion.EJ2.Inputs

<div id='speechtotext-container'>
    <ejs-speechtotext id="speech-to-text" enableRtl=true transcriptChanged="onTranscriptChanged">
        <e-speechtotext-buttonSettings content="Start Listening" stopContent="Stop Listening"></e-speechtotext-buttonSettings>
    </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>
    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>
public ActionResult Rtl()
{
    return View();
}

RTL