Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to make a button-controlled “music box” that plays different sounds depending on which buttons are pressed. In this lesson, we will configure our raspberry pi for voice control.
What will you learn?
Like the Amazon Echo, voice-activated gadgets are becoming increasingly popular, but you can also construct your own with a Raspberry, a cheap USB mic, and some appropriate software. Simply speaking to your Raspberry Pi will allow you to search YouTube, view websites, activate applications, and even answer inquiries.
What will you need?
Because the Raspberry Pi lacks a soundcard or audio port, this project requires a USB microphone or a camera with a built-in microphone. If your mic only has an audio jack, look for an affordable USB soundcard that connects to a USB port on one side and has a headphone and mic output on the other.
Getting started
For the Raspberry Pi, there are various speech recognition programs. We’re utilizing Steve Hickson’s Pi AUI Toolkit for this project since it is powerful and straightforward to set up and operate. You may install a variety of programs using the Pi AUI Suite. The first question is whether or not the dependencies should be installed. These are the files that the Raspberry Pi requires to work with voice commands, so pick Yes, then press Enter to agree.
Following that, you’ll be asked if you wish to download the PlayVideo software, which allows you to open and play video content using voice commands. If you select Y, you’ll be prompted to enter the location of your media files, such as /home/pi/Videos. It’s worth noting the upper-case letters are crucial in this scenario. The application will tell you if the route is incorrect.
Next, you’ll be asked if you wish to download the Downloader application, which explores the internet for files and downloads them for you automatically. If you select Yes, you will be prompted to enter an address, port, password, and username. If you’re not sure, press Return to choose the default settings in each scenario for now.
Install the Google Texts to Speech Service if you require your raspberry pi to read the contents of the text files. Since it communicates to Google servers to translate text into speech, the Raspberry Pi must be hooked up to the internet to utilize this service.
You’ll require a google user account to install this. The installation requests your username—press Return after completing this step. The Google password is then requested. Return to the previous page and type this.
You may also use the installer to download Google Voice Commands. This makes use of Google’s speech-to-text technology. To proceed, you must enter your Google login and password once again.
Regardless of whether you choose Google-specific software or not, the program will ask if you wish to download the YouTube scripts. These technologies allow you to say something like “play pi tutorial,” An appropriate video clip will be played—press Return after typing a new welcome. You can also enable the silent flag to prevent the Raspberry Pi from responding verbally.
Lastly, the software installs the Voice command, which includes some of the more helpful scripts, such as the ability to deploy your internet browser by simply saying “internet.”
Basic voice commands used
Youtube: When you say “YouTube” followed by a title tag, a youtube clip of the first related YouTube clip appears. “I’m feeling lucky” is comparable to “I’m feeling lucky” on google. Say “YouTube” followed by the title of the video you want to watch, for example, “YouTube fluffy kittens.”
Internet: Your internet browser is launched when you use the word “internet.” Midori is the internet browser for Rpi by default, but you may alter that.
Download: When you say “download,” followed by a search query, the Pirate Bay webpage searches for the files in demand. For instance, you can say “Download Into the badlands” to get the most current edition of the movie.
Play: This phrase utilizes the in-built media player to open an audio or video file. For instance, “Play football.mp4” would play the file “football.mp4” from the media directory you chose during setup, like /home/pi/movies.
Show me: When you say “show me,” a directory of your choice appears. The command defaults to not going to a valid root directory, so you’ll need to modify your configuration so that it points to one. For instance, show me==/Documents.
You’ll be asked if you want the Voice command to set things up automatically. If an issue occurs at this point, run the following command to download and install the required software.
Configuring the Raspberry Pi master voice
After installing the Voice command application, you may want to perform a few basic adjustments to the setup to fine-tune it. Execute the following command from your Raspberry Pi’s Terminal or via SSH.
Following that, you’ll be asked several yes/no questions. The first question is whether you wish to enable the continuous flag permanently. The Voice command application, in clear English, asks if you would want to listen to your voice commands constantly every time you launch it.
For the time being, choose Yes. After that, you’ll be asked if you wish the Voice command application to set the verify flag permanently. If you select Y, the application will expect you to pronounce your keyword (the default setting is “Pi”) before responding to requests.
If you like the RPi to monitor continually but not act on all words you say, this is a good option.
The next step asks if you wish to enable the ignore flag permanently. If Voice command receives a command that isn’t expressly listed in the config file, it will try to find and launch a program from your installed apps. For example, if you say “leafpad,” a notepad tool, the Voice command looks for it and starts it even if you don’t tell it to.
This is a functionality that we would not recommend anyone to enable. Because you’re using Voice command at the SuperUser level, there’s a significant danger that you’ll accidentally issue a command to the Raspberry Pi that will harm your files. If you wish to set up other programs to function with the Voice command, you can update the configuration file for each scenario.
The voice command afterward asks if you want to permanently enable the silence flag so that it doesn’t respond verbally whenever you talk. As you see fit, select yes or no. After that, you’ll be prompted to adjust the default voice recognition timeframe. If Pi is having problems hearing your commands, you should modify this.
If you select Yes, you’ll be prompted to enter a number; this is the number of seconds that the Raspberry Pi will listen for a voice command; the default for RPI is 3. The application then allows you to customize your text-to-speech choices. Before you do this, make sure your volume is turned up. The application attempts to speak something and then asks if you heard it.
When the system receives your keyword, it responds with “Yes, sir?” as the default response. To modify this, select Yes in the following prompt, then enter your chosen response, for example, “Yes, ma’am?” Once you’re finished, hit the enter key. The program will replay the assigned response to check that you are satisfied with the outcome.
Whenever the program receives an unidentified command, the method is the same as the default response. “Received the wrong command” is set as the default response, but you could still alter it to something more friendly by typing yes, then your desired response, like, “The command is not known.”
You now have the option of configuring the voice recognition parameters. This will check to see if you have a suitable mic. The Pi will then ask you if you want it to test your sound threshold using the Voice command.
Check for background sound, then press Yes, then press enter key. It then requests you to say a command to ensure that it is using the correct audio device. Type Yes to have the application automatically select the appropriate audio threshold for your Rpi.
Lastly, the Raspberry Pi will ask if you wish to modify the default voice command term (“Pi”). After that, type Y and your new keyword, then press enter when you’re finished.
After that, you’ll be requested to say your keyword to acclimate the RPi to your voice. If everything looks good, press Y to finish the setup. Start with the fundamental commands outlined above when using the Voice command software.
Once you’ve mastered these commands, use the following line of code to exit the application and, if desired, change your config file.
Vexing sounds and how to get rid of them
The Raspberry Pi’s technology is still a work-in-progress, so not everything you speak may be recognized by the program.
Stay near the mic and talk slowly and clearly to maximize your chances of being heard by the program if you still have difficulties understanding. Launch the terminal or log in through SSH to your Raspberry Pi and type the following command to access your audio settings to change your audio preferences.
Hit the F4 button on the keyboard to select audio input, then the F6 key to exit. Select your input device, the mic with the arrow up or down keys, then press Enter key. To change the mic’s volume, push it up using the up-arrow key to maximum (100).
If your device isn’t identified at all, it may require more current than a universal serial bus port on a Raspberry Pi can supply. A powered universal serial bus hub is the ideal solution for this.
If you have difficulty connecting after installing the Download application, please ensure that connection to The Pirate Bay site is not limited.
To download the files, you’ll also require a BitTorrent application for your RPi, such as transmission. To install this, launch your terminal or access your RPi through SSH and type the following command:
The Transmission homepage has instructions about getting started and utilizing the application. You should always download files that have permission from the copyright holder.
Please remember that whatever you speak and any text documents you provide are transferred to Google servers for translation if you use Google text or speech Commands.
Google maintains that none of this information is kept on its servers. Even if this is the case, any data communicated through the worldwide web can be decrypted by any skilled third party or a hacker. Google, however, encrypts your connection to minimize the risk of this happening.
If you like this voice command tool, you might want the program to launch automatically every time the Rpi is powered on. If this is the case, launch the terminal from your RPi or access it via SSH and execute the command below:
The above command opens the script that controls which programs run whenever your Raspberry Pi is booted. By default, this script is doing nothing. Type the following line of code directly above the one reading exit 0:
To save any changes, use Ctrl+X, enter yes, and press enter key. At this point, you can restart the Raspberry Pi to ensure that it is working.
Launch your Rpi terminal, type the command below, and press enter to see a list of active processes.
How can we reduce vexing noise?
Noise from air conditioners and heaters can damage your audio and make it impossible for the program to understand what you’re saying. The only other alternative is to turn these systems off during recording unless the entire system is redesigned to be more acoustically friendly. However, upon listening to the audio, it becomes clear and annoying.
Computer hardware cooling fans are also sources of mechanical noise. These can be disabled manually and for a limited period. Besides that, try isolating the disturbance in another space or utilizing an isolation box as an alternative.
Conclusion
We learned how to configure our raspberry pi for voice control. We also looked at a few basic commands used to control the raspberry pi and the software used. However, In the following tutorial, we will learn how to tweet on Raspberry pi.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
The post Voice Control Project using Raspberry Pi 4 appeared first on The Engineering Projects.
No comments:
Post a Comment