Cov txheej txheem:
- Kauj Ruam 1: ReSpeaker USB 4-Mic Array
- Kauj Ruam 2: Txhim Kho Cov Tsev Qiv Ntawv
- Kauj Ruam 3: Text-to-speech hauv Python Nrog Pyttsx3 Library
- Kauj Ruam 4: Muab Nws Tag Nrho Ua Ke: Txhim Kho Kev Hais Lus Nrog Python Siv Google Speech Recognition API thiab Pyttsx3 Library
Video: Kev Paub Hais Lus Siv Google Speech API thiab Python: 4 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Paub Hais Lus
Kev Paub Hais Lus yog ib feem ntawm Kev Hais Lus Ntuj uas yog lub hauv paus ntawm Artificial Intelligence. Txhawm rau muab nws yooj yim, kev hais lus paub yog lub peev xwm ntawm lub khoos phis tawj siv los txheeb xyuas cov lus thiab kab lus hauv kev hais lus thiab hloov lawv mus rau tib neeg nyeem cov ntawv. Nws tau siv hauv ntau daim ntawv thov xws li lub tshuab pabcuam suab, kev siv lub tsev, lub suab raws li chatbots, lub suab cuam tshuam nrog neeg hlau, kev txawj ntse txawj ntse thiab lwm yam.
Muaj ntau qhov APIs (Application Programming Interface) rau kev lees paub hais lus. Lawv muab cov kev pabcuam pub dawb lossis them nyiaj. Cov no yog:
- CMU Sphinx: koj puas xav tau ntau tus thwjtim?
- Google Hais Lus Paub
- Google Cloud Speech API
- Wit.ai
- Microsoft Bing Lub Suab Kev Paub
- Houndify API
- IBM Hais Lus Rau Cov Ntawv
- Kev Tshawb Nrhiav Snowboy Hotword
Peb yuav siv Google Kev Hais Lus Hais Lus ntawm no, vim nws tsis xav tau ib tus lej API. Phau ntawv qhia no lub hom phiaj los muab cov lus qhia yuav ua li cas siv Google Kev Hais Lus Kev lees paub lub tsev qiv ntawv ntawm Python nrog kev pab ntawm lub microphone sab nraud zoo li ReSpeaker USB 4-Mic Array los ntawm Pom Studio. Txawm hais tias nws tsis tas yuav siv lub microphone sab nraud, txawm tias siv lub microphone ntawm lub khoos phis tawj tuaj yeem siv tau.
Kauj Ruam 1: ReSpeaker USB 4-Mic Array
ReSpeaker USB Mic yog lub tshuab ntaus plaub lub microphone tsim los rau AI thiab lub suab thov, uas tau tsim los ntawm Seeed Studio. Nws muaj 4 qhov ua tau zoo, ua-nyob rau hauv omnidirectional microphones tsim los khaws koj lub suab los ntawm txhua qhov chaw hauv chav thiab 12 qhov programmable RGB LED ntsuas. ReSpeaker USB mic txhawb Linux, macOS, thiab Windows operating systems. Cov ntsiab lus tuaj yeem pom ntawm no.
ReSpeaker USB Mic los hauv pob zoo uas muaj cov khoom hauv qab no:
- Ib tus neeg siv phau ntawv qhia
- ReSpeaker USB Mic Array
- Micro USB rau USB Cable
Yog li peb npaj tau pib.
Kauj Ruam 2: Txhim Kho Cov Tsev Qiv Ntawv
Txog qhov kev qhia no, Kuv xav tias koj siv Python 3.x.
Cia peb nruab cov tsev qiv ntawv:
pip3 nruab SpeechRecognition
Rau macOS, ua ntej koj yuav tsum teeb tsa PortAudio nrog Homebrew, thiab tom qab ntawd nruab PyAudio nrog pip3:
brew nruab portaudio
Peb khiav hauv qab cov lus txib rau nruab pyaudio
pip3 nruab pyaudio
Rau Linux, koj tuaj yeem nruab PyAudio nrog apt:
sudo apt-tau nruab python-pyaudio python3-pyaudio
Rau Windows, koj tuaj yeem nruab PyAudio nrog pip:
pip nruab pyaudio
Tsim cov ntaub ntawv nab npawb tshiab
nano tau_index.py
Muab tshuaj txhuam rau get_index.py hauv qab cov lej snippet:
ntshuam pyaudio
p = pyaudio. PyAudio () info = p.get_host_api_info_by_index (0) numdevices = info.get ('deviceCount') rau kuv hauv ntau (0, numdevices): yog (p.get_device_info_by_host_api_device_index (0, i) '))> 0: print ("Input Device id", i, " -", p.get_device_info_by_host_api_device_index (0, i).get (' lub npe '))
Khiav cov lus txib hauv qab no:
python3 get_index.py
Hauv kuv qhov xwm txheej, hais kom ua cov hauv qab no rau qhov screen:
Cov Khoom Siv ID 1 - ReSpeaker 4 Mic Array (UAC1.0)
Cov Ntaus Ntaus ID 2 - MacBook Air Microphone
Hloov cov cuab yeej_index rau tus lej lej raws li qhov koj xaiv hauv qab cov lej ntu.
ntshuam speech_recognition li sr
r = sr. Recognizer () hais lus = sr. Microphone (device_index = 1) nrog hais lus raws li qhov chaw: luam tawm ("hais qee yam! …") suab = r.adjust_for_ambient_noise (qhov chaw) suab = r.listen (qhov chaw) sim: rov ua dua = r.recognize_google (audio, language = 'en-US') print ("Koj hais tias:" + recog) except sr. UnknownValueError: print ("Google Speech Recognition could not understand audio") except sr. RequestError as e: print ("Tsis tuaj yeem thov cov txiaj ntsig los ntawm Google Kev Pabcuam Hais Lus Paub; {0}". Hom ntawv (e))
Cov cuab yeej ntsuas tau xaiv 1 vim ReSpeaker 4 Mic Array yuav yog lub hauv paus tseem ceeb.
Kauj Ruam 3: Text-to-speech hauv Python Nrog Pyttsx3 Library
Muaj ntau qhov APIs muaj los hloov cov ntawv rau hais lus hauv nab hab sej. Ib ntawm cov APIs yog pyttsx3, uas yog qhov zoo tshaj plaws muaj cov ntawv-rau-hais lus pob hauv kuv lub tswv yim. Cov pob no ua haujlwm hauv Windows, Mac, thiab Linux. Txheeb xyuas cov ntaub ntawv raug cai los saib seb qhov no ua tiav li cas.
Nruab pob pob Siv cov pip los nruab pob.
pip nruab pyttsx3
Yog tias koj nyob hauv Windows, koj yuav xav tau pob ntxiv, pypiwin32 uas nws yuav xav tau nkag mus rau Windows ib txwm hais lus API.
pip nruab pypiwin32
Hloov cov ntawv rau hais lus nab hab sej tsab ntawv hauv qab no yog tus lej snippet rau cov ntawv rau kev hais lus siv pyttsx3:
ntshuam pyttsx3
engine = pyttsx3.init ()
engine.setProperty ('tus nqi', 150) # Ceev feem pua
engine.setProperty ('ntim', 0.9) # Ntim 0-1
engine.say ("Nyob zoo, ntiaj teb!")
engine.runAndWait ()
Kauj Ruam 4: Muab Nws Tag Nrho Ua Ke: Txhim Kho Kev Hais Lus Nrog Python Siv Google Speech Recognition API thiab Pyttsx3 Library
Cov cai hauv qab no yog lub luag haujlwm lees paub tib neeg hais lus siv Google Kev Paub Hais Lus, thiab hloov cov ntawv los ua lus hais siv pyttsx3 lub tsev qiv ntawv.
ntshuam speech_recognition li sr
ntshuam pyttsx3 cav = pyttsx3.init () engine.setProperty ('tus nqi', 200) engine.setProperty ('ntim', 0.9) r = sr. Recognizer () hais lus = sr. Microphone (device_index = 1) nrog hais lus ua qhov chaw: audio = r.adjust_for_ambient_noise (source) audio = r.listen (source) sim: recog = r.recognize_google (audio, language = 'en-US') print ("Koj hais tias:" + recog) engine.say (" Koj hais tias: " + recog) engine.runAndWait () tshwj tsis yog sr. UnknownValueError: engine.say (" Google Kev Hais Lus Tsis tuaj yeem nkag siab lub suab ") engine.runAndWait () tshwj tsis yog sr. RequestError li e: engine.say (" Ua tsis tau thov kom tau txais txiaj ntsig los ntawm Google Kev Pab Hais Lus Hais Lus; {0} ". format (e)) engine.runAndWait ()
Nws luam tawm cov zis ntawm lub davhlau ya nyob twg. Tsis tas li, nws yuav hloov pauv mus rau kev hais lus ib yam.
Koj tau hais tias: London yog lub peev ntawm Great Britain
Kuv vam tias tam sim no koj muaj kev nkag siab zoo ntawm kev hais lus paub ua haujlwm li cas thiab qhov tseem ceeb tshaj plaws, yuav ua li cas thiaj li siv Google Kev Hais Lus Paub API nrog Python.
Yog tias koj muaj lus nug lossis tswv yim? Tawm lus tawm hauv qab no. Nyob twj ywm!
Pom zoo:
Cov Hais Lus Ua Los Ntawm Cov Khoom Siv Rov Los thiab Rov Siv Dua: 6 Cov Kauj Ruam
Cov Hais Lus Ua Los Ntawm Cov Khoom Siv Rov Los thiab Rov Los Siv Rov Los: " Suab paj nruag yog cov lus thoob ntiaj teb ntawm tib neeg. Thiab qhov zoo tshaj plaws-lawv tsis tau them kuv ib dime. Txhua yam nyob rau hauv no pr
Kev Paub Hais Lus Nrog Arduino (Bluetooth + LCD + Android): 6 Cov Kauj Ruam
Kev Paub Hais Lus Nrog Arduino (Bluetooth + LCD + Android): Hauv qhov haujlwm no, peb tab tom ua qhov hais lus paub nrog Arduino, Bluetooth module (HC-05) thiab LCD. cia peb tsim koj tus kheej cov cuab yeej paub hais lus
Kev Paub Duab Nrog K210 Cov Ntsiab Lus thiab Arduino IDE/Micropython: 6 Cov Kauj Ruam (nrog Duab)
Kev Paub Duab Nrog K210 Cov Thaj Tsam thiab Arduino IDE/Micropython: Kuv twb tau sau ib tsab xov xwm hais txog yuav ua li cas qhib OpenMV qhov kev nthuav qhia ntawm Sipeed Maix Bit thiab tseem tau ua yeeb yaj kiab ntawm kev ntsuas pom qhov pom zoo nrog lub rooj tsavxwm no. Ib qho ntawm ntau cov lus nug tib neeg tau nug yog - kuv tuaj yeem lees paub lub hom phiaj li cas tias neural network tsis yog
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej
Predicitive Txij Nkawm Ntawm Cov Tshuab Rotating Siv Kev Ruaj Ntseg thiab Cov Lus Hais: 8 Kauj Ruam
Predicitive Txij Nkawm Ntawm Cov Tshuab Rotating Siv Kev Ruaj Ntseg thiab Kev Hais Lus: Lub tshuab tig ib yam li cua tshuab cua, lub tshuab hluav taws xob, lub tshuab nqus hluav taws xob thiab lwm yam ntsej muag sib txawv ntawm hnav thiab kua muag. Feem ntau ntawm cov kev ua txhaum no thiab hnav thiab tsim kua muag tshwm sim los ntawm kev ua tsis zoo hauv lub cuab yeej. Cov tshuab no feem ntau ua haujlwm nyob rau hauv hnyav-du