In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares with you is about the process of making raspberry pie voice intelligent conversation chat robot. The editor thinks it is very practical, so I share it with you to learn. I hope you can learn something after reading this article. Let's take a look at it with the editor.
Hardware
Raspberry pie 3B, USB sound card, Mike, USB stereo
Software
Python, Baidu speech recognition API, Turing Robot, espeak
The official raspberry pie system comes with a python environment.
Baidu speech recognition api
Register Turing robot
Access to Turing robot
The next test program tests the correct access of the Turing robot.
Create a py file on the raspberry pie:
#-*-coding: utf-8-*-
Import urllib
Import json
Def getHtml (url):
Page = urllib.urlopen (url)
Html = page.read ()
Return html
If _ _ name__ = ='_ _ main__':
Key = 'your api key'
Api = 'http://www.tuling123.com/openapi/api?key=' + key +' & info='
While True:
Info = raw_input ('me:')
Request = api + info
Response = getHtml (request)
Dic_json = json.loads (response)
Print 'robot:' .decode ('utf-8') + dic_json [' text']
After saving, you can run the text-to-text chat. What we want is a conversation. So the text input here has to be changed into voice input. Then I will call Baidu Voice api to help me extract the text from the voice. Then the reply text of the Turing robot is said through the espeak through the stereo.
Here, raspberry pie itself does not have a sound card. Fortunately, there is an omnipotent treasure. Looking for raspberry pie USB sound card.
When we plug in this USB sound card, it can actually be used. Because the raspberry pie actually has a popular device driver built into it. Then we need to install the corresponding recording program on the raspberry pie.
1. Update the software package first
2.sudo apt-get update
3.sudo apt-get upgrade
4.install # install the necessary programs
5.sudo apt-get-y install alsa-utils alsa-tools alsa-tools-gui alsamixergui
Here installed the necessary recording tools, but also installed two graphical interface tools, so that you can use the graphical interface to set the volume, etc., the operation will be more convenient.
After the installation is complete, you can use raspberry pie to record. Let's record it for 60 seconds:
1.arecord-D "plughw:1,0"-d 60 / tmp/test.wav
Among them, the plughw:1,0 here is the external sound card device, and-D represents the designated device. It is worth mentioning here that if the output file is not set later, the data generated by the recording after executing the command will be displayed directly on the terminal. So you can actually write something like this:
1.arecord-D "plughw:1,0"-d 60 > / dev/test.wav
After that, you can also install a graphical interface of audacity audio editing software, so you can edit and produce your music album on raspberry pie.
1.apt-get-y install audacity
Plug in the USB sound card, then start audacity, and you can see your USB sound card device in the recording input. If you want to play also from the USB sound card in the playback USB device can be selected ~ the default is to play from the raspberry pie.
Baidu speech synthesis and recognition
Then play the text and voice replied by the Turing robot.
To be lazy, I use espeak software. Sudo apt-get install espeak
When the students are installed, you can test the terminal to run espeak-vzh. I'm a robot.
Enter raspberry pie will play "I'm a robot."
If it is not in Chinese, you can directly espeak hello world.
This is how the raspberry pie voice intelligent conversation chat robot is made. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.