Standalone Arduino Speech Maker
by Lithium-ion in Circuits > Arduino
604 Views, 4 Favorites, 0 Comments
Standalone Arduino Speech Maker
A simple Arduino based talking project, now you can also play your voice on that. let's encode the simple audio files to Arduino audio files
Supplies
Components required:
Arduino Nano
Speaker with amplifier
Battery and wires
PCM convertor software: Audacity
Wav to Arduino convertor: Arduino MP3 tool download from here
Story
In the last tutorial we made an image to OLED displayer. Image files are converted into Arduino compatible file and send to display on OLED. But today we are going to work with sound files. We will convert the audio files to Arduino compatible files and then drive a speaker directly using the PWM feature inside Arduino. In this way no DAC is needed anymore, whatever is the quality it is coming directly from the microcontroller’s heart. Basically, Pulse code modulation is working here, we are sampling the sound in a manner every step is recorded.
This will create a huge file for the small audio. So, keep the Arduino’s flash memory in mind. We can convert 2-3 lines only into the speech which is to be send one after the another. In this tutorial I will let you how to make Arduino compatible file from simple audio file. Even you can also your own voice and then play it using Arduino. We can use this projects which need sound interaction. Arduino commands can be arranged to any specific task and then to play the respective audio.
Win Exciting Rewards From PCBWAY:
PCBWAY is hosting a PCB design competition 5th time and now there are rewards for everybody. Just register on the website and get your hands on raspberry pi Pico board.
You can share your projects and thoughts there to win more prices. Just upload the full working of your best project using PCBWAY service. Want to know more about contest then click here.
Making the Audio Files Compatible to Arduino:
First: Go to online text to speech convertor and download the audio file in wav format using smallest possible sampling rate.
Second:
Then open this file into Audacity, keep the sampling rate to 8000 and export in 16-bit PCM format. This will convert the audio into 16bit codec but Arduino is compatible to 8-bit data, which required more conversion.
Third:
Download this Arduino convertor tool from here. Extract all the files. Then go to Arduino MP3 folder and then to encode audio. Which has an exe tool file. Now run that file and it will redirect you to choose audio file, choose the previously exported audacity file. Tool will copy the Arduino compatible to code directly to the clipboard of your laptop.
Fourth:
Now go to downloaded Arduino MP3 folder again, you will find an Arduino library named as PCM. Include this file into Arduino IDE.
Fifth:
Open the library examples, which is shown as playback. This file contains an audio string already, now replace that line with your code. Just delete that file and paste your data which is already on copied to your clipboard.
See this video from one of my friend for proper visual instructions.
Arduino Programming & Connections:
Now the interface is clean, connect your Arduino. Choose the right com port and board settings and then click to upload the file. This will upload the recorded file.
Arduino D11 pin is chosen by default for the output by PCM library. Connect the positive of speaker to Arduino D11 pin and negative to GND of Arduino. This will repeat the code on every reset and play the audio file. A small speaker can be directly derived using Arduino pin but to use the big speaker an audio amplifier is needed to make powerful sound output. I am not recommended to use Class D amplifier with this setup.
Audio Quality:
Because we are playing the files directly on PWM of Arduino. Which is just a misbehaving to the Arduino. Because there is no digital to analog convert on Arduino and this audio playback is only done for maximum 2-3 lines. If you want to play this using amplifier then it is worst idea to make an Arduino speech convertor. The quality is really low, which is just recognizable.
Troubleshooting and Errors:
While using the Arduino MP3 encoder audio tool, I faced an error which is from javaw.exe. Here is the solution to that also the tool has program running in JavaScript format. And because this is the only tool available on internet to encode the audio in Arduino format. Follow these steps:
1) Go to the link and then install the java compiler software form oracle: http://goo.gl/lGbF5B
2) You have to login oracle to download this java file.
3) Then install the download software to the windows drive and the error is automatically resolved,
There is just some missing file which need to compile with that java.exe and I am not working on java these days that’s why I don’t have installed software in my laptop.
Arduino Form PCBWAY:
I made my own Arduino using PCBWAY prototype service. PCBWAY is China based PCB manufacturer and working for more than 15 years in this industry. This Arduino is exactly same as available in market. Fully compatible with the IDE and I added type C for a better user experience. I am using PCBWAY prototyping service for a long time for my project.
The prototypes are charged $5 for 10pcs of 2layer designs. You can also try the more services from PCBWAY like Stencil, PCBA, SMT assembly, CNC and 3D printing. Register now and get new user free coupons to available to you.