File Exchange

image thumbnail


Automatic speech-to-text conversion


Updated 20 Feb 2019

View License

Automate labeling and tagging of speech recordings, assess the performance of DSP pipelines for voice and speech enhancement, run text analytics on voice recordings, and more.
This entry enables you to convert sampled speech recordings available as MATLAB vectors into strings using a single function call.
You will need a license of Audio System Toolbox, an internet connection, and an active subscription to a speech-to-text service of your choice – Google™ Cloud Speech-to-Text API, IBM™ Watson Speech to Text API, or Microsoft™ Azure Speech Services API.

Please check out the Examples tab for detailed instructions on how to get started.

Cite As

MathWorks Audio System Toolbox Team (2019). speech2text (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (22)

Hello.. I keep getting an error.. I'm Using the Google Speech Recognition API but everytime I try to run it I got this error message:
Error using coder.internal.error (line 14)
Unable to access speech2text. Make sure the file is
installed. Go to File Exchange to download. For more
information, click here.

Error in speechClient

Error in speechtest (line 1)
speechObject =

Hello Grayson,

The downloaded speech2text files may not be on your MATLAB Search path (

Please addpath your downloaded speech2text folder ( or cd to it before running the speech2text commands.

Hope this helps.

Hi there,
I am trying to use Google's Speech recognition API, but every time I try to make a speechClient I get this error:
Error using coder.internal.error (line 14)
Unable to access speech2text. Make sure the file is installed. Go to File Exchange to download. For more information, click here.

Error in speechClient

I've checked multiple times and speech2text is definitely installed. I also do have the audio system toolbox installed. Any idea what I'm doing wrong?
Thanks in advance.

Hello Oliver,

It looks like you are using the ‘languageCode’ to pass the model name for IBM, but you would need to pass it using ‘model’, something like:

transcriber = speechClient('IBM','model','es-ES_NarrowbandModel');

This is the expected Name-Value as mentioned in the IBM documentation -

Hope this helps!

Oliver Sell


I am using the IBM Watson Speech API. When I run this function I get the following error:

'Bad Request' 400 'This 8000hz audio input requires a narrow band model. See https://<STT_API_ENDPOINT>/v1/models for a list of available models.'

I tried 'en-US_NarrowbandModel' as 'languageCode' but it still does not work. How can I pass the variable 'model' 'en-US_NarrowbandModel' or change the model?

Thank you in advance.

Priyal Goel

Hello, I get the following error when I run:
[y,fs] = audioread('youre-on-the-right-track.wav');
speechObject = speechClient('Microsoft','recognition','interactive','language','en-US');
tableOut = speech2text(speechObject,y,fs)

Output argument "tableOut" (and maybe others) not assigned during call to "speechClient/speechTotext".

Error in speech2text

Error in sampleTesting (line 4)
tableOut = speech2text(speechObject,y,fs)

I'm using the Microsoft Azure Bing API
Can someone please help me with this?

@Sumit Mondal - Thank you for reporting this. It looks like this error was triggered by the absence of a license for Audio System Toolbox, which is required by speech2text. The lack of clarity of the actual error message will be fixed in an upcoming update.

The errors I get when trying to run the speech2text() function are the following :
Unable to find message key 'noAudio' in catalog 'signal:sigtools'.

Error in speechClient.checkoutASTLicense

Error in speechClient/speechTotext

Error in speech2text

Does anyone know what the problem could be ?

Is there any way to enable word time onsets and offsets in the Google API? See:

On the frequently encountered error "Expected input to be a vector" - Please note that the second input argument y of the speech2text function needs to be either a column or a row vector, i.e. an array having one of its dimensions equal to 1. It is very common for audio recordings to be stored in stereo format, so you may want to check the size of your audio array before using speech2text, for example by looking at your MATLAB workspace. If your audio array has multiple channels (typically resulting in a number of columns greater than 1), you need to select only one of them. Good options for stereo signals include either the left channel, i.e. y = readAudio(:,1), the right channel, i.e. y = readAudio(:,2), or their average across channels, i.e. y = mean(readAudio,2)

thank you I have emailed you @gabriele

@Sunaina Aytan - Thank you for your getting in touch. Please send more information on the error you are getting, including full reproduction steps, using

hi i keep getting this error please help

Error using speechClient/speechTotext
Expected input to be a vector.

Error in speech2text

sneha madre

Sam, you are saving the JSON file incorrectly. The contents of JSON file for IBM should only contain the "username" and "password" obtained from your IBM Speech API account. Also, don't forget to include the parenthesis - "{" at the beginning and, "}" at the end of your JSON file.

In the downloaded folder, you should see 'writing_IBM_JSON.png' inside the HTML sub-folder. This image will help you with writing the JSON file for the IBM API.

Hope this helps!

Sam Cocks

When creating the .json file using IBM, I get an error on the jsondecode function where it is reading the save information of the file first:

Error using jsondecode
JSON syntax error at line 1, column 1 (character 1): expected value but found 'MATLAB'.

Opening my json file in matlab gives this as my first row:

MATLAB 5.0 MAT-file, Platform: MACI64, Created on: Wed

Am I saving my json incorrectly?


another issue. when I try to process larger files, matlab returns The connection to URL '' timed out after 10 seconds. Set HTTPOptions.Timeout to a higher value..but I don't have the option to set the timeout value as they are protected .m files..


Arh I figured it out. this happened when google api can't detect any speech..


Hiya, I've got this error when I run:

[samples,fs] = audioread('handel.wav');
speechObject = speechClient('Google','languageCode','en-US');
tableOut = speech2text(speechObject,samples,fs)

Reference to non-existent field 'results'.

Error in speechClient/showOutput

Error in speechClient/googleAPI

Error in speechClient/speechTotext

Error in speech2text

Error in speech2textconvert (line 8)
tableOut = speech2text(speechObject,samples,fs)

Excellent One.


Addressed compatibility issues in older MATLAB releases (R2017a and R2017b)

Added support for new authentications schemes for IBM and Microsoft APIs.

Corrected path update on install

Improved handling of errors and lack of data in responses when using Microsoft API.

Updates for changes to IBM API

Added files under Files/en to enable cmd line help for p-coded files.

Added HTTPTimeOut option to allow using longer speech recordings.
Added error message to better handle a scenario where an HTTP request is successful but the API does not return any transcription data

MATLAB Release Compatibility
Created with R2018b
Compatible with R2017a to any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor