Recognize Audio Input as Text with Machine Learning in C#

Cloudmersive
2 min readFeb 21, 2022

Transposing audio uses up a lot of time that we usually don’t have. With the /speech/recognize/file iteration of the Cloudmersive Speech API, you can easily turn audio into text, and incorporate that function into your C# application using ready-to-run code from the Cloudmersive API Console.

To start off, install the .NET Framework SDK using the below command:

Install-Package Cloudmersive.APIClient.NET.Speech -Version 4.0.1

Next, copy in the callback function. Under public void main (), you’ll need to provide your Cloudmersive API key — if you don’t already have one, you can easily make a free account on the Cloudmersive website & receive a key (good for 800 monthly API calls).

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.Speech.Api;
using Cloudmersive.APIClient.NET.Speech.Client;
using Cloudmersive.APIClient.NET.Speech.Model;
namespace Example
{
public class RecognizeFileExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
var apiInstance = new RecognizeApi();
var speechFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Speech file to perform the operation on. Common file formats such as WAV, MP3 are supported.
try
{
// Recognize audio input as text using machine learning
SpeechRecognitionResult result = apiInstance.RecognizeFile(speechFile);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling RecognizeApi.RecognizeFile: " + e.Message );
}
}
}
}

--

--

Cloudmersive

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