How to Record Audio Speech as Text in Node.JS

In important meetings, negotiations, or conferences, proper notes and memos must be recorded to preserve speech. Thus, converting recorded audio to text is a useful tool to instantly create a hard copy of spoken word. This may also be helpful when receiving voicemail or in adding accessibility features to your website. For example, those who cannot hear audio would benefit from having access to a visual representation of the speech. This API will show you how to automatically convert any MP3 or WAV file to text.

Image for post
Image for post

We will first need to install the SDK:

npm install cloudmersive-speech-api-client --save

You can also add this snippet to your package.json:

"dependencies": {
"cloudmersive-speech-client": "^1.1.5"
}

Now, let’s call our function:

var CloudmersiveSpeechApiClient = require('cloudmersive-speech-api-client');
var defaultClient = CloudmersiveSpeechApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveSpeechApiClient.RecognizeApi();var speechFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Speech file to perform the operation on. Common file formats such as WAV, MP3 are supported.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.recognizeFile(speechFile, callback);

With that, you can upgrade your transcription capabilities and improve overall accessibility across your programs. You can get your free API Key from Cloudmersive, giving you access to 800 monthly calls across our API library.

Written by

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

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