For an index to all my stories click this text.
I was fascinated by the talking clock and thermometer I build with the ESP32, but the audio quality was crap. It was like I heard an old Commodore 64 or Apple do speech synthesises in the eighties. At that time this was amazing but nowadays we want a better quality.
Raspberry pi pico audio is superior.
Then I stumbled on something amazing. The humble Raspberry Pi Pico can produce outstanding audio quality. The only thing we need for that is a Pico or a Pico W, 6 resistors and 2 capacitors. These are used as a simple low-pass filter. I am going to build some projects with this. We'll start with a talking thermometer and next a talking clock. In the end I will add some buttons and an SD card-reader and presto: A cheap MP3 player.
For those who want to build these projects you will need the following items:
- a Raspberry Pi Pico or Pico W
- 2 1K resistors
- 6 2.2K resistors
- 2 47nF capacitors
- Dallas DS18B20 digital thermometer
- 4k7 pull up resistor
And for the MP3 player you will need:
- SD card adapter for ESP8266 or ESP32 or
- an SD card adapter for micro SD cards (often included).
These will set you back between 6 Euro and 9 Euro depending on using the Pico or the Pico W. I present this list now so you can order them from your favorite electronics supplier so you have them in time when we start building the hardware next week.
How to get the audio files
For the talking clock and the talking thermometer you will need several audio files. The best parts is that you can use your own voice for this. And if your voice sounds like sandpaper (like mine) find someone in your family or friends that have a pleasant voice to help you.
As the Pico and Pico W have limited memory we need the audio files to be as small as possible. Therefore we will record them at 8K resolution and not the ussual 44k resolution. Next to that the MicroPython libraries can only play WAV files. So we need to record or audio files in 8K .wav format.
To record these audio files we will use audacity.
Audacity
Audacity is free open source audio software that is available for Windows, Mac and Linux.
Audacity can import and export WAV, AIFF, MP#, AU, FLAC and Ogg Vorbis files. You can import multiple files and combine them into one and then export them in any of the mentioned formats. This feature makes it ideal for (for example) converting MP3 files to WAV files or any other format you might need.
Next to Audacity you will need a Microphone. The better the Microphone the better the audio quality will be. However a simple stand alone version does the trick also. And if you do not want to spend money on a dedicated microphone the microphone in your webcam will also do the job.
Start by downloading and installing Audacity. You can find it here:
https://www.audacityteam.org/
Recording the audio files.
This is the opening screen. I changed the settings into a dark theme which I personally find easier to work with. Besides that the high contrast makes it easier to edit your audio recordings.
In the edit tab on the top of the screen choose preferences. In the preferences pop-up screen choose Interface and there choose the Theme of your choice. Like said: I prefer high contrast.
While in the preferences menu go to the Devices settings and choose which microphone you are going to use. I have two microphones on my PC. A stand alone Realtec Audio and the microphone in my WC150 web-cam. I choose the stand-alone microphone for my recordings.
Before starting your audio recordings change the project rate at the bottom of the screen to 8000. This will sample your audio recordings at 8K which is required for our project. Dont forget to set this value back to 44100 for the highest quality when you use Audacity for other purposes.
Now you can start your audio recordings by pressing the red record button at the top of the screen.
The recording stops by pressing the grey stop button. And you can listen to what you have recorded by pressing the play button.
In the main screen appear the waves that your recording made. In the above example you can see that I started a bit to late with talking and waited too long before I pressed the stop button. You can check that yourself by pressing the play button. While playing there is a line on the screen that shows where in the timeline the audio that you hear is.
For our Pico project we do not want any silences in the audio. If we need a pause in the audio we will let the program make that pause. So here the sound needs to get as short as possible.
Use your mouse to select the exact audio part you need without the silences. After selecting you can test if you made the right selection by pressing the play button.
In the edit menu select Remove Special and then Trim Audio and the parts that are not selected will be removed.
Now you can save your recording. Choose Export from the file menu and save it5 as a WAV file.
That's it. We have made our first recording.
Before going on to the next step, play around with Audacity. There is a lot to discover and you might use it for other projects then just the Pico Audio Project.
The Pico Audio project.
As stated in the beginning of this story we are going to build a talking thermometer and a talking clock. Our thermometer will be able to speak the temperatures from 1 to 59 degrees. The clock can say the hours from 1 to 24 and the minutes from one to 59.
So we need the following numbers and text:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50,
it is now, hour, minutes, degrees.
We do not need numbers like 21 to 29, 31 to 39 etc as we can make them by for example using 20 and then 5.
In the upcoming stories we are first going to do a test to see if the hardware on the Pico is working as expected. For this also record a sentence like:
"Hello world, this is the Raspberry Pi Pico talking"
Save this using the filename: hello.wav
So your "homework" for now is to record the above mentioned numbers and texts and save them in files in a directory on your computer.
Naming the audio files for the numbers needs some special attention. To make the files easily accessible for our program save the audio files with their number as their name. For example save 1 as "1.wav", 15 as "15.wav" etc. Save the recording of "it is now" as "itsnow.wav". For the other words use the word as the filename.
Next week I am going to discuss how to build the low pass filter with the above mentioned resistors and capacitors.
Till then.
Have fun
Luc Volders