| 1234567891011121314151617181920212223242526272829303132333435 |
- import logging
- import base
- import tts
- import clips
- import ears
- _LISTEN_TIMEOUT = 600
- _GROCERIES = ['milk', 'bread']
- class WunderbarTodo(base.BaseFunction):
- def _groceries(self):
- tts.tts('ready')
- lines, terminator = ears.listen_until_terminated(timeout=_LISTEN_TIMEOUT, preferred_phrases=_GROCERIES)
- if terminator == 'cancel':
- tts.tts('cancelled')
- return
- else:
- items = []
- for line in lines:
- items.extend([t.strip() for t in line.split(' and ') if t.strip()])
- logging.info(items)
- tts.tts('ok')
- def call(self, trigger=None, **_):
- if trigger == 'food':
- self._groceries()
- else:
- tts.tts('Bad trigger')
|