Introducing Voice API Speech Recognition

Published June 02, 2020 by Victor Shisterov

We recently announced a new Automatic Speech Recognition (ASR) feature which enables your application to understand what humans are saying when they speak. This feature allows you to create a full range of voice interactions from simple IVRs with voice navigation, to sophisticated voice bots and assistants.

Using ASR you can provide customers with the fastest service possible, easily enable speech-based self-serve operations, whilst delivering a superior user experience, and reducing operational costs. In this post, we’ll show you how to build a simple IVR app a user can navigate using only their voice.

Vonage API Account

To complete this tutorial, you will need a Vonage API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the Vonage API Dashboard.

Before You Begin

To start, please be sure you have a Vonage API account and that you have created a voice application.

We will use Node.js for this example, as well as the Express web application framework and the body-parser packages. For ease you can use the NPM command below to install them into your project:

Although this example uses Node.js, it is possible to recreate the same functionality using your preferred code language/framework by using the same NCCO as we show below.

Writing the Code

Speech recognition is activated by the NCCO input command, which is also suitable for capturing DTMF tones. Assuming you have a number assigned to your application already, create a new file called index.js and start by implementing the answer webhook as shown in the code below:

In the code snippet above:

uuid is the call (leg) identifier and is a required parameter for this action. You can get this UUID from the answer webhook query params.

bargeIn: true in the talk action allows the user to start speaking at any moment while the Text to Speech message is being played, which might be suitable if the user has already heard this message on a previous call.

context in the input action increases the accuracy of speech recognition and is suitable for IVR-style cases.

When the user says the department name and the word is recognized by Vonage, you’ll get a webhook callback to the event_url you specified in the input action. The request body for this callback contains speech recognition results and looks like this:

Next, you need to implement a webhook that decides what to do with the information returned by ASR:

In the snippet above, you should replace the departmentNumber values with some other phone numbers so you can receive a call to, and from number to one of your Nexmo account numbers.

Finally, create your Node.js server:

Testing Your Application

To begin testing locally you will need to expose your local server to the rest of the world so that your answer and event_url webhooks can be reached. You can use Ngrok to do this by following the Testing with Ngrok guide in our documentation.

With your app running call the number associated with the application you created in the dashboard. You will hear the greeting message with IVR options and be able to connect to one of your numbers by saying the department name.

Try to add other options and different words to capture, for example, instead of announcing the options in the greeting, keep just the question quite generic and then try to analyze the user’s answer by searching for the words “sales”, “support” or even “buy” to convert the IVR to a smart assistant.

What’s Next?

Should you have any questions or feedback let us know on our Community Slack or by getting in touch on

Leave a Reply

Your email address will not be published.

Get the latest posts from Nexmo’s next-generation communications blog delivered to your inbox.

By signing up to our communications blog, you accept our privacy policy , which sets out how we use your data and the rights you have in respect of your data. You can opt out of receiving our updates by clicking the unsubscribe link in the email or by emailing us at