Convert Text to Speech in multiple languages using Asp.Net Core & C#

In this article, we are going to learn how to convert text to speech in multiple languages using one of the important Cognitive Services API called Microsoft Text to Speech Service API ( One of the API in Speech API ).

C# (1013.0 KB)
 
 
 
 
 
(0)
265 times
Add to favorites
10/20/2018
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
@model TextToSpeechApp.Models.SpeechModel

@{
    ViewData["Title"] = "Home Page";
}

<form asp-controller="Home" asp-action="Index" method="post">
    <div class="form-group">
        <div class="row">
            <h2>Text To Speech</h2>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
                <label asp-for="LanguageCode" class="control-label"></label>
                <select asp-items="Model.LanguagePreference" class="btn btn-default dropdown-toggle" id="ddlLangCode" asp-for="LanguageCode"></select>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
                <textarea asp-for="Content" rows="10" cols="40" class="alert-info"></textarea>
                <button type="submit" class="btn btn-success">Convert</button>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
                <label class="control-label">Play Voice</label>
                <audio controls>
                    <source src="@Url.Action("Translate", "Home", new { token = ViewBag.Token, key = ViewBag.Key, content = ViewBag.Content , lang = ViewBag.LangCode  })" type="audio/mpeg">
                    Your browser does not support the audio element.
                </audio>
            </div>
        </div>
    </div>
</form>