Ejemplo n.º 1
0
def listen_keyboard():
    data_path = 'Data/Train_Data/Keyboard'
    if not os.path.exists(data_path):
        os.makedirs(data_path)

    def on_press(key):
        save_event_keyboard(data_path, 1, key)

    def on_release(key):
        save_event_keyboard(data_path, 2, key)

    with key_listener(on_press=on_press, on_release=on_release) as listener:
        listener.join()
Ejemplo n.º 2
0
		output = current_outputs[0]
	elif key == Key.right:
		output = current_outputs[1]
	elif key == Key.up:
		output = current_outputs[2]
	elif key == Key.down:
		output = current_outputs[3]
	elif key == Key.space:
		output = current_outputs[4]

	play_sound('sounds/{}.wav'.format(output))

def on_click(x, y, button, pressed):
	global current_keyboard
	if pressed:
		current_keyboard = (current_keyboard + 1) % 3
		print("Switched to Keyboard #{}".format(current_keyboard+1))


play_sound('sounds/do.wav')
time.sleep(0.2)
play_sound('sounds/re.wav')
time.sleep(0.2)
play_sound('sounds/mi.wav')


with key_listener(on_release=on_release) as keyboard, mouse_listener(on_click=on_click) as mouse:
	mouse.join()
	keyboard.join()