def __init__(self): espeak.init() self.speaker = espeak.Espeak()
def speech_rec_for_linux(): import espeak espeak.init() speaker = espeak.Espeak() # import pyttsx3 # speaker = pyttsx3.init() r = sr.Recognizer() text = "" count = 0 medicines = {} with sr.Microphone() as source: while (True): medicine_dict = {} count += 1 print("Medicine-" + str(count) + " Information") print("Adjusting noise ") r.adjust_for_ambient_noise(source, duration=1) print("Medicine Name:") speaker.say("Medicine name") # speaker.rate = 300 recorded_audio = r.listen(source, timeout=6) print("Done") try: text = r.recognize_google(recorded_audio, language="en-US") if 'exit' in str(text).lower(): print("Thanks for using our service!") break medicine_dict["Medicine Name"] = str(text) print("Decoded Text : {}".format(text)) except Exception as e: print(e) print("Adjusting noise ") r.adjust_for_ambient_noise(source, duration=1) print("Medicine Instruction:") speaker.say("Medicine Instruction") recorded_audio = r.listen(source, timeout=6) print("Done") try: text = r.recognize_google(recorded_audio, language="en-US") medicine_dict["Instruction"] = str(text) print("Decoded Text : {}".format(text)) except Exception as e: print(e) medicines["Medicine No. " + str(count)] = medicine_dict return medicines
GPIO.output(pin2, GPIO.LOW) def forward(pin1, pin2): GPIO.output(pin1, GPIO.HIGH) GPIO.output(pin2, GPIO.LOW) def backward(pin1, pin2): forward(pin2, pin1) while True: ## Initializing ## espeak.init() speaker = espeak.Espeak() print("Finding ps3 controller...") devices = [evdev.InputDevice(fn) for fn in evdev.list_devices()] ps3dev = None for device in devices: print(device.path, device.name, device.phys) if device.name == 'Sony PLAYSTATION(R)3 Controller': ps3dev = device.fn print(ps3dev) else: print("Other device") if ps3dev is None: sleep(2) continue gpio_setup()