Mise à jour de 'mss.py'
add comment
This commit is contained in:
8
mss.py
8
mss.py
@@ -39,13 +39,13 @@ def on_message(client, userdata, msg):
|
|||||||
def publish(client):
|
def publish(client):
|
||||||
global msg
|
global msg
|
||||||
while True:
|
while True:
|
||||||
robot_ear = speech_recognition.Recognizer()
|
robot_ear = speech_recognition.Recognizer() # khởi tạo biến bien robot_ear
|
||||||
with speech_recognition.Microphone() as mic:
|
with speech_recognition.Microphone() as mic: # khởi tạo biến mic (with giúp dừng thu tiếng)
|
||||||
print("robot : im listen")
|
print("robot : im listen")
|
||||||
audio = robot_ear.listen(mic)
|
audio = robot_ear.listen(mic) # khởi tạo biến audio = dl nghe được từ mic
|
||||||
|
|
||||||
try:
|
try:
|
||||||
msg = robot_ear.recognize_google(audio)
|
msg = robot_ear.recognize_google(audio) # chuyển dl nghe đc sang dạng text
|
||||||
except:
|
except:
|
||||||
msg = ""
|
msg = ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user