Welcome to DOFBOT SE repository
11.Garbage Recognition with Voice Broadcast
Yolov11 Garbage Recognition Broadcast
1. Function Description
Voice broadcast of the recognized garbage name and garbage type.
2. Startup and Operation
2.1 Startup
First, you need to start the ROS node service. Open the terminal and enter the following:
xxxxxxxxxxros2 run dofbot_info kinemarics_dofbot
Then open another terminal and enter the following:
xxxxxxxxxxpython3 ~/dofbot_voice/scripts/garbage_broadcast.py
2.2 Operation Steps
Place the garbage label block in the middle of the image. Say "Hi, yahboom" to the voice module. The voice module replies "I'm here" indicating successful wake-up. Then say "What garbage is this?". After the program recognizes it, the voice module will broadcast what garbage it is and the garbage type. Taking the figure below as an example, according to the recognition result, it will reply "This is a peach pit, which belongs to dry garbage".

3. Core Code Analysis
Source code path: ~/dofbot_voice/scripts/garbage_broadcast.py
x# Import voice broadcast garbage type libraryfrom speech_garbage import speech_garbage# Mainly look at the content of this library# Import garbage recognition libraryfrom garbage_identify import garbage_identify# Call garbage recognition function, pass the current image as parameter, then return the processed image and recognition resultself.frame, msg = self.garbage_identify.garbage_run(self.frame)# Iterate through the recognition result msg, according to the value of name to determine the garbage name representing number self.garbage_num and type self.garbage_classfor key, pos in msg.items(): name = key if name == "Zip_top_can": (self.garbage_num, self.garbage_class) = ('00', '01') if name == "Old_school_bag": (self.garbage_num, self.garbage_class) = ('01', '01') if name == "Newspaper": (self.garbage_num, self.garbage_class) = ('02', '01') if name == "Book": (self.garbage_num, self.garbage_class) = ('03', '01') if name == "Toilet_paper": (self.garbage_num, self.garbage_class) = ('04', '02') if name == "Peach_pit": (self.garbage_num, self.garbage_class) = ('05', '02') if name == "Cigarette_butts": (self.garbage_num, self.garbage_class) = ('06', '02') if name == "Disposable_chopsticks": (self.garbage_num, self.garbage_class) = ('07', '02') if name == "Egg_shell": (self.garbage_num, self.garbage_class) = ('08', '03') if name == "Apple_core": (self.garbage_num, self.garbage_class) = ('09', '03') if name == "Watermelon_rind": (self.garbage_num, self.garbage_class) = ('10', '03') if name == "Fish_bone": (self.garbage_num, self.garbage_class) = ('11', '03') if name == "Expired_tablets": (self.garbage_num, self.garbage_class) = ('12', '04') if name == "Expired_cosmetics": (self.garbage_num, self.garbage_class) = ('13', '04') if name == "Used_batteries": (self.garbage_num, self.garbage_class) = ('14', '04') if name == "Syringe": (self.garbage_num, self.garbage_class) = ('15', '04') if name == "None": (self.garbage_num, self.garbage_class) = ('None', 'None')# Get voice recognition resultresult = mySpeech.speech_read()# If the current voice recognition result is 94, it means asking what garbage it isif result == 94: # According to self.garbage_num to broadcast the current garbage name and garbage type if self.garbage_num == '00': mySpeech.void_write(94) elif self.garbage_num == '01': mySpeech.void_write(95) elif self.garbage_num == '02': mySpeech.void_write(96) elif self.garbage_num == '03': mySpeech.void_write(97) elif self.garbage_num == '04': mySpeech.void_write(109) elif self.garbage_num == '05': mySpeech.void_write(108) elif self.garbage_num == '06': mySpeech.void_write(107) elif self.garbage_num == '07': mySpeech.void_write(106) elif self.garbage_num == '08': mySpeech.void_write(105) elif self.garbage_num == '09': mySpeech.void_write(104) elif self.garbage_num == '10': mySpeech.void_write(103) elif self.garbage_num == '11': mySpeech.void_write(102) elif self.garbage_num == '12': mySpeech.void_write(101) elif self.garbage_num == '13': mySpeech.void_write(100) elif self.garbage_num == '14': mySpeech.void_write(99) elif self.garbage_num == '15': mySpeech.void_write(98)