Perform Text-to-Speech on a String in C#

Is your writing just not speaking to you? You can take matters into your own hands with the Cloudmersive Speech API and convert written text to spoken language. You can then specify either MP3 or WAV file formats for the outcome of this operation. Let’s quickly walk through connecting in two easy steps in C# via the Cloudmersive API Console.

First things first, install the .NET Framework SDK:

Install-Package Cloudmersive.APIClient.NET.Speech -Version 4.0.1using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.Speech.Api;
using Cloudmersive.APIClient.NET.Speech.Client;
using Cloudmersive.APIClient.NET.Speech.Model;

Then, for your second & final step, copy in the C# callback function and include your Cloudmersive API key where indicated.

namespace Example
{
public class SpeakTextToSpeechExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
var apiInstance = new SpeakApi();
var reqConfig = new TextToSpeechRequest(); // TextToSpeechRequest | String input request
try
{
// Perform text-to-speech on a string
Object result = apiInstance.SpeakTextToSpeech(reqConfig);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling SpeakApi.SpeakTextToSpeech: " + e.Message );
}
}
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.