Adding IP phones to my rack (Part 2)
Building upon the initial setup of an Asterisk PBX on a Raspberry Pi, this post explores the implementation of an Interactive Voice Response (IVR) system to add advanced functionality to a home telephone network. The process involves creating a custom menu structure for managing family extensions and utilizing ElevenLabs to generate natural-sounding AI voices for automated prompts. Finally, the guide covers the technical requirements for converting these audio files into the specific 8 kHz mono WAV format necessary for seamless integration with telephony hardware.
More Gear for the Rack: IP Telephony (Part 2)
I really did not plan to write this Part 2 about the software, but what I built was so fun and interesting that I could not resist sharing it.
In Part 1, I explained that I had acquired a couple of IP phones and set up a basic configuration so my family and I could call each other. Since the second phone has not arrived yet (I am still waiting for its delivery), I decided to focus on the software in the meantime. I built something very fun and, looking back at it now, quite interesting as well.
1. The Idea
Since we already had an Asterisk PBX configuration running on the Raspberry Pi that only allowed family members to call each other through extensions, I thought: what else could we do? I decided to explore the possibility of adding more advanced features, specifically an IVR (Interactive Voice Response) system, which allows users to interact with the system through voice menus and keypad options.

What Is an IVR?
An IVR (Interactive Voice Response) is a system that allows users to interact with a telephone service through voice menus and keypad options. For example, when you call a company and hear a message saying, "Press 1 for sales, press 2 for support," you are interacting with an IVR.
It is commonly used in call centers, technical support services, and any situation where interaction with users needs to be automated over the phone.
For example, when you call your internet service provider and hear a message saying, "Press 1 for technical support, press 2 for billing," you are interacting with an IVR.
I knew almost nothing about the subject, but I had always been curious about how this worked and how it could be implemented in a home environment.
2. The Idea for My Home IVR
I wanted something simple and interesting, such as an automated "telephone directory" for my home, where I could call and quickly get information about other family members and their numbers, or include an option such as: press 5 to call a specific family member directly.
When someone dials 5000, Asterisk answers the call, initializes the attempt counter, and waits one second before playing the greeting. It then sends the call to the main menu. This short delay prevents the beginning of the audio from being cut off on some phones.
INICIO
└── Llaman al 5000
├── Answer() # Asterisk answers the call
├── Set(IVR_ATTEMPTS=0) # Start with no failed attempts
├── Wait(1) # Let the audio establish
├── Playback(custom/bienvenida-familia)
└── Goto(ivr-familia,s,1) # Go to the family menu
The Main Menu
The menu-familia message explains what each key does. While it is playing, Background() allows the caller to select an option without waiting for the audio to finish. If nothing is pressed for five seconds, the t case (timeout) is triggered.
Each option places an internal call using Dial(). The number after PJSIP/ identifies the destination phone, and 120 is the maximum wait time in seconds. The m(cisco) option plays hold music while the other person answers.
[ivr-familia]
├── Background(custom/menu-familia)
├── WaitExten(5)
├── 1 → John Doe (3004) → Dial(PJSIP/john-doe3004,120,m(cisco))
├── 2 → Alex Smith (1404) → Dial(PJSIP/alex-smith1404,120,m(cisco))
├── 3 → Jane Doe (2406) → Dial(PJSIP/jane-doe2406,120,m(cisco))
├── 4 → Taylor Lee (0301) → Dial(PJSIP/taylor-lee0301,120,m(cisco))
├── 5 → Jamie Brown (1603)→ Dial(PJSIP/jamie-brown1603,120,m(cisco))
├── 9 → Repetir el menú → Goto(ivr-familia,s,1)
└── 0 → Despedirse y salir → Playback(custom/despedida-familia), Hangup()
After each call attempt, resultado-llamada is executed. If the person answers, ANSWER returns control to the normal flow. If the line is busy, there is no answer, or the phone is unavailable, a different message is played and the caller is asked what they would like to do.
[resultado-llamada]
├── ANSWER → Return() # The call was answered
├── BUSY → Playback(custom/ocupado)
├── NOANSWER → Playback(custom/no-contesta)
├── CANCEL → Playback(custom/no-contesta)
└── Otro → Playback(custom/no-en-linea)
What Happens When Nobody Answers
For any of the cases above except ANSWER, the system enters preguntar. It offers two alternatives: return to the family menu or end the call. This way, a missed call does not automatically turn into a confusing error for the person using the IVR.
[preguntar]
├── Background(custom/volver-a-llamar)
├── WaitExten(10)
├── 1 → Goto(ivr-familia,s,1) # Try another person
├── 2 → Playback(custom/llamada-finalizada), Hangup()
├── i → Avisar de la opción inválida y volver a preguntar
└── t → Avisar que no hubo selección y volver a preguntar
Invalid options and timeouts increase REINTENTOS_RESULTADO. Two attempts are allowed to prevent the call from getting stuck in an infinite loop; after that, it moves to ivr-end. The same idea is used in the main menu through IVR_ATTEMPTS: if two incorrect options are entered or the timeout occurs twice, the farewell message is played and the call is ended.
[ivr-end]
└── Playback(custom/despedida-familia)
└── Hangup() # End the call cleanly
The "Cisco" Music
I call it "Cisco" because it is the same track Cisco used as hold music in its telephone systems. Specifically, the track "Opus Number One."
Now we have another problem: how do we make it speak?
3. The Voices
This is the most fun and interesting part of the process: giving our telephone system a voice. This is where we can configure the voices that will be used for automated messages, IVR prompts, and any other type of communication generated by the system.
I do not know whether there is a more practical or professional method, but I remembered my years of experience creating content, such as Loquendo videos, which used synthesized voices to narrate stories or explain concepts. This gave me the idea of applying a similar approach to our telephone system and creating automated messages with software-generated voices.
The Problem with AI: TTS Was Left Behind
TTS (Text-to-Speech) is a technology that converts text into speech. However, its implementation was limited and inflexible in many traditional telephone systems. With the rise of artificial intelligence, the concept of "AI-generated voice" emerged, making it possible to achieve much more natural and customizable results for our telephone system.
Since I was fond of that robotic voice from the old Siri or Google Translate, finding a place to generate voices with that same style proved difficult. Many people therefore turned to more modern AI-based TTS solutions, which allow the tone, speed, and intonation of a voice to be adjusted so that it sounds more natural and appropriate for each situation.
This is where the ElevenLabs platform comes in.

ElevenLabs is a platform that generates realistic voices from text using artificial intelligence. It offers a wide variety of voices and customization options, allowing us to create automated messages that sound natural and appropriate for our telephone system.
How to Use ElevenLabs

As shown in the image, we simply enter the text we want to convert into speech, select the desired voice, and adjust the customization settings according to our needs. We can then generate the audio file that will be used in our telephone system.
For this, I randomly chose a voice with a Spanish accent. Although I am not from Spain, I was simply curious. I started generating texts such as:
"Welcome to our telephone system. Please select an option from the menu." "To speak with a representative, press 1." "To hear our promotions, press 2." "To leave a message, press 3." "The selected option is not valid. Please try again." "The person is currently unavailable. Please try again later." "Would you like to perform another action? Press 1 for yes or 2 for no." "Thank you for using our telephone system. Have a nice day."
This part was a lot of fun, as I was able to experiment with different voices and styles and hear the messages I had written come to life. It felt like giving our telephone system a personality, and it reminded me of my days creating content with synthesized voices.
Now, to make everything work, we need to convert the voices to a specific format. Nothing too complicated.
4. The .wav Audio Format
The .wav audio format is widely used in telephone systems because of its compatibility and sound quality. To make sure our recordings work correctly, we need to convert the files generated by ElevenLabs to this format.
ElevenLabs files can generally be downloaded in formats such as .mp3 or .ogg, so we need a converter to transform them into .wav files. This can be done using tools such as Audacity, FFmpeg, or any other reliable audio converter.
For example, using FFmpeg, the command would be:
ffmpeg -i archivo_original.mp3 archivo_convertido.wav
This gives us messages in the appropriate format for integrating them into our telephone system.
The file must have a bit depth of at least 16 bits and a sampling rate of 8 kHz, which is the standard for telephone systems. This ensures that the audio is clear and understandable for users.
In FFmpeg, we can make sure these requirements are met with the following command:
ffmpeg -i archivo_original.mp3 -ar 8000 -ac 1 -sample_fmt s16 archivo_convertido.wav
Here, -ar 8000 sets the sampling rate to 8 kHz, -ac 1 converts the audio to mono, and -sample_fmt s16 ensures a 16-bit format. With this, our files are ready to be used in the telephone system.
To be honest, it sounds pretty bad in this format, but it is more than enough for telephony.
In short, converting our recordings to the .wav format with the appropriate specifications is a crucial step in ensuring that our telephone system works properly and that users have a clear and understandable audio experience.
You can review the rest of the code on my GitHub, where I have uploaded all the files and examples needed to replicate this telephone system in your own environments. A detailed README.md explains how to configure and use the system step by step.
You can find the repository at the following link: My GitHub.
To Be Continued in Part 3
All that remains is for my other IP phone to arrive so I can test the entire system under real conditions. In the future, we will implement more features and devices at the same time; perhaps we will migrate to a more advanced system or integrate additional services such as video calls and instant messaging.
See you next time, and may the Force be with you.
Post images