Asterisk AEAP Speech to Text: res_aeap Setup Guide
Set up Asterisk speech to text over AEAP: configure res_aeap in aeap.conf, write the dialplan, and run the Asterisk reference app.
By Arkay · Updated · Published

What is AEAP and what is it used for?

AEAP, the Asterisk External Application Protocol, lets Asterisk exchange configuration, data and other information with an outside program. It uses a simple request/response messaging system (AEAP overview in the Asterisk docs). For speech to text, the outside program does the recognition, and Asterisk's speech applications read its results.
The AEAP overview says JSON is currently the only supported message format. In this guide, the outside program is the Asterisk project's reference app, which is covered later.
Which Asterisk versions support AEAP speech to text?
The res_aeap module is available since Asterisk 18.12.0 and 19.4.0 (res_aeap module documentation). The reference app says it works with Asterisk 18.12.0 and later and 19.4.0 and later (aeap-speech-to-text on GitHub).
The speech applications and functions come from app_speech_utils, which has been available since 1.6.1.0. Check your server's version before you start, so you know which of these pieces you have.
What did we compile for this guide, and was it tested?
We compiled this guide on November 14, 2026, from two sources. The first is the official Asterisk documentation on docs.asterisk.org, including the API pages generated from branch 23. The second is the README of the Asterisk project's reference app on GitHub. Each fact below links to the page it came from.
Nothing was tested or run. We did not place a call through this setup, so treat the steps as a checklist to verify on your own system. The IP address, port and names in the examples are example values taken from the README or chosen for illustration.
How do I configure res_aeap in aeap.conf?
Asterisk reads the client section from aeap.conf. The README's reference section looks like this:
[my-speech-to-text]
type=client
codecs=!all,ulaw
url=ws://127.0.0.1:9099
protocol=speech_to_text
Each line sets one option for the client. The section name, my-speech-to-text, becomes the speech engine name. You pass that name to SpeechCreate in the dialplan, so keep the two in step. The table explains each option.
| Option | What it does |
|---|---|
| type | Must be client. |
| url | The URL of the server Asterisk connects to. The README uses ws://127.0.0.1:9099. |
| protocol | The application protocol. The README uses speech_to_text. |
| codecs | Optional. If set, it is used for codec negotiation with the external application. If not set, Asterisk uses the codecs configured on the endpoint. |
The option details come from the res_aeap module documentation. The README sets codecs to !all,ulaw. The url must match the address your speech server listens on. With the reference app's default port, that address ends in 9099.
What messages does AEAP send between Asterisk and the external app?
AEAP has three request types. setup initializes the remote application, get retrieves settings, and set updates them. A setup request must be the first request sent. After setup is accepted, get and set requests can follow (AEAP overview).
Every request and response carries a request or response field and an id field. A setup request also needs a version field. The docs example uses version 0.1.0 and the ulaw codec. An error response adds an error_msg field with a text description of the error.
The docs show a get request that asks for a language setting:
{
"request": "get",
"id": "example-id",
"params": ["language"]
}
Neither the official docs nor the README document the speech-specific AEAP message formats. If you need them, read the reference app's source code, because the README does not describe them either.
Is there a ready-made AEAP speech-to-text server I can run?
Yes. The aeap-speech-to-text repository is an example Node.js program that uses AEAP for external speech to text in Asterisk 18.12.0 and later and 19.4.0 and later. It acts as a mediator between Asterisk and the Google speech provider. The program is licensed under Apache-2.0.
To run it, you need Node.js and Google Speech API credentials. You set the credentials in the GOOGLE_APPLICATION_CREDENTIALS environment variable. The aeap-speech-to-text README lists these steps.
How do I run the reference server?

Download the source of the aeap-speech-to-text repository from GitHub, then follow these steps:
- From the top of the source tree, install the packages with npm install.
- Set GOOGLE_APPLICATION_CREDENTIALS to your Google Speech API credentials.
- Start index.js. It runs a websocket server on the default port, 9099.
- To use another port, pass --port with your port number. Then set the same port in the url option of aeap.conf.
The commands, in order, look like this:
npm install
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
node index.js
For another port, run node index.js --port=<port number> instead. Press Ctrl-C to stop the server. Asterisk connects to this server through the url you set in aeap.conf, so the address and port in both places must agree.
What dialplan applications do I use to recognize speech?

The speech applications below come from app_speech_utils, which has been available since 1.6.1.0. Their descriptions come from the SpeechCreate, SpeechStart, SpeechBackground, SpeechActivateGrammar and SpeechDestroy pages.
| Application | What it does |
|---|---|
| SpeechCreate(engine_name) | Creates the speech structure. It must run before any other speech activity. With no name, it uses the default engine. |
| SpeechStart() | Tells the engine to start getting results from the audio. |
| SpeechBackground(sound_file[&...][,timeout[,options]]) | Plays a file and waits for speech. |
| SpeechActivateGrammar(grammar_name) | Activates a grammar for the engine to recognize. |
| SpeechDestroy() | Destroys the speech data. SpeechCreate must run again before you recognize more speech. |
The README's dialplan for extension 550 shows the order of the speech steps:
exten => 550,1,NoOp()
same => n,Answer()
same => n,SpeechCreate(my-speech-to-text)
same => n,SpeechStart()
same => n,SpeechBackground(hello-world)
same => n,Verbose(0,${SPEECH_TEXT(0)})
same => n,SpeechDestroy()
same => n,Hangup()
Answer answers the call if it is not already answered. SpeechCreate opens the engine named my-speech-to-text, which is the section name from aeap.conf. SpeechStart begins recognition. SpeechBackground plays the hello-world sound file and waits for speech. Verbose writes the recognized text to verbose output. SpeechDestroy then clears the speech data, and Hangup ends the call.
What does SpeechBackground do with its timeout and options?
The syntax is SpeechBackground(sound_file[&...][,timeout[,options]]). Playback of the file stops once the caller starts speaking. The timeout is in seconds. It starts only after the sound file has stopped playing, so a long prompt does not eat into the silence window. Once results are available, the application returns, and you read them with dialplan functions.
The n option does not answer a channel that is not yet answered. The p option returns partial results when the backend is stopped by the timeout. That lets you keep what was recognized before the timeout ended. Both options are listed on the SpeechBackground page.
What can go wrong, and how do I spot it?
SpeechCreate sets the ERROR channel variable to 1 if the engine cannot be used. Check that variable right after SpeechCreate if you want to handle the failure yourself.
SpeechStart hangs up the channel on failure. If you want the dialplan to continue instead, run it through TryExec, as the SpeechStart page describes.
SpeechDestroy ends recognition for the channel. Any later speech work needs a new SpeechCreate. If your dialplan recognizes speech more than once, plan for that call.
If the reference app is not running, or its url and port do not match, Asterisk cannot reach the speech server. Check that the server is running and that the url in aeap.conf points to it.
What advanced examples can I build from these pieces?
The examples below use only the pieces covered above. The first repeats the README's section pattern with a second engine. Its name and address are example values.
[my-second-speech]
type=client
url=ws://speech.example.com:9099
protocol=speech_to_text
Because this section has no codecs line, Asterisk uses the codecs configured on the endpoint. The section name, my-second-speech, is the engine name you give to SpeechCreate in the next example.
The second example is a dialplan that logs what it recognized. It replaces the README's extension 550, so use it in place of that example, not beside it:
exten => 550,1,NoOp()
same => n,Answer()
same => n,SpeechCreate(my-second-speech)
same => n,SpeechStart()
same => n,SpeechBackground(hello-world)
same => n,Verbose(0,Results: ${SPEECH(results)})
same => n,Verbose(0,Text: ${SPEECH_TEXT(0)} Score: ${SPEECH_SCORE(0)})
same => n,SpeechDestroy()
same => n,Hangup()
Verbose sends each message to verbose output. The first line logs the number of results with SPEECH(results). The second logs the recognized text and confidence score of result 0 with SPEECH_TEXT(0) and SPEECH_SCORE(0). SPEECH(results) tells you whether there is anything to read, so check it before you use the text.
To add a timeout and partial results, use the syntax from the SpeechBackground section above and pass the timeout and the p option as its second and third arguments.
Nothing in these examples was run. Test them on your own system before you rely on them.
More guides in Open-Source PBX and SIP Servers.
Frequently asked questions
- Which codec should the AEAP client use?
- The sources do not require a particular codec. The README sets codecs to !all,ulaw, and the AEAP docs example for setup also uses the ulaw codec. If you leave codecs out of aeap.conf, Asterisk uses the codecs configured on the endpoint.
- How do I read the recognized text and confidence score in the dialplan?
- Use SPEECH(results) to check how many results were recognized. Then read result n with SPEECH_TEXT(n) for the text and SPEECH_SCORE(n) for the confidence score. The README's example uses SPEECH_TEXT(0).
Sources
- AEAP (Asterisk External Application Protocol) passes configuration, data and other informa (docs.asterisk.org)
- res_aeap is configured in aeap.conf with [client] sections, and is available since Asteris (docs.asterisk.org)
- The Asterisk project's aeap-speech-to-text repository is an example Node.js program that u (github.com)
- SpeechCreate(engine_name) creates the speech structure and must be called before any other (docs.asterisk.org)
- SpeechStart() tells the engine to start getting results from the audio, and hangs up the c (docs.asterisk.org)
- SpeechBackground(sound_file[&...],[timeout,[options]]) plays a file and waits for speech; (docs.asterisk.org)
- SpeechActivateGrammar(grammar_name) activates a grammar for the engine to recognize. (docs.asterisk.org)
- SpeechDestroy() ends recognition and frees the speech data; SpeechCreate must be called ag (docs.asterisk.org)