convert feeding game to use voice input

Change-Id: I5df6a7997871ecd0054b02e80fca7167cdc3266e
diff --git a/raspimon_eats.py b/raspimon_eats.py
index 18fd8d5..ce24478 100644
--- a/raspimon_eats.py
+++ b/raspimon_eats.py
@@ -1,6 +1,7 @@
 from sense_hat import SenseHat
 from time import sleep
 from random import randint
+import voice
 
 sense = SenseHat()
 
@@ -60,6 +61,17 @@
   global direction
   direction = event.direction
 
+def change_direction(label):
+  global direction
+  if label.endswith("up"):
+    direction = "up"
+  elif label.endswith("down"):
+    direction = "down"
+  elif label.endswith("left"):
+    direction = "left"
+  elif label.endswith("right"):
+    direction = "right"
+
 def add_berry():
   x = randint(0, 7)
   y = randint(0, 7)
@@ -68,13 +80,21 @@
   berries.append(new)
 
 # Main program ------------------------
-sense.clear() 
+sense.clear()
 sense.stick.direction_any = joystick_moved
+listener = voice.AudioClassifier(model_file=voice.VOICE_MODEL,
+                                 labels_file=voice.VOICE_LABELS,
+                                 audio_device_index=2)
 
 for _ in range(5):
   add_berry()
 
 while True:
+  command = listener.next(block=False)
+  if command:
+    label, score = command
+    change_direction(label)
+    print(label, score)
   move()
   sleep(DELAY)
   if len(berries) == 0:
diff --git a/voice.py b/voice.py
index f789a4e..a11e54b 100644
--- a/voice.py
+++ b/voice.py
@@ -208,6 +208,7 @@
   keep_listening = True
   prev_detection = -1
   with recorder:
+    print("Ready for voice commands...")
     while keep_listening:
       spectrogram = feature_extractor.get_next_spectrogram(recorder)
       if spectrogram.mean() < 0.001: