Ejemplo n.º 1
0
 def test_phone(self):
     """
     Test for the get_phone function
     """
     numbers = get_phone(text)
     self.assertEqual(len(numbers), 
                      5)
Ejemplo n.º 2
0
 def play(self, filename):
     # FIXME: Use platform-independent audio-output here
     # See issue jasperproject/jasper-client#188
     gruephone = phone.get_phone()
     cmd = [
         '/usr/bin/aplay', '-D', 'plughw:{},0'.format(self.device),
         str(filename)
     ]
     self._logger.debug('Executing %s',
                        ' '.join([pipes.quote(arg) for arg in cmd]))
     run_while(gruephone.off_hook, cmd[0], cmd)
Ejemplo n.º 3
0
    def __init__(self,
                 speaker,
                 passive_stt_engine,
                 active_stt_engine,
                 echo=False):
        """
        Initiates the pocketsphinx instance.

        Arguments:
        speaker -- handles platform-independent audio output
        passive_stt_engine -- performs STT while Jasper is in passive listen
                              mode
        acive_stt_engine -- performs STT while Jasper is in active listen mode
        """
        self._logger = logging.getLogger(__name__)
        self.setSpeaker(speaker)
        self.passive_stt_engine = passive_stt_engine
        self.active_stt_engine = active_stt_engine
        self.phone = phone.get_phone()
        self._logger.info("Initializing PyAudio. ALSA/Jack error messages " +
                          "that pop up during this process are normal and " +
                          "can usually be safely ignored.")
        self._audio = pyaudio.PyAudio()
        self._logger.info("Initialization of PyAudio completed.")
        self._echo = echo  # whether to play back what it heard

        self._audio_dev = None
        profile_path = jasperpath.config('profile.yml')
        if os.path.exists(profile_path):
            with open(profile_path, 'r') as f:
                profile = yaml.safe_load(f)
                if 'audio_dev' in profile and 'speaker' in profile['audio_dev']:
                    self._audio_dev = profile['audio_dev']['mic']
        if self._audio_dev is None:
            self._audio_dev = 0
        self.keep_files = False
        self.last_file_recorded = None
        self.RATE = 44100
        self.CHUNK = 32
        self.TARGET_RATE = 16000
        self.THRESHOLD_MULTIPLIER = 1.8
        self.dial_timeout = 2.5
        self._dial_stack = []

        self.start_background_threshold_thread()
Ejemplo n.º 4
0
 def test_phone(self):
     numbers = get_phone(text)
     #self.assertEqual(len(numbers), 5)
     # when RE is fixed, all numbers are returned
     self.assertEqual(len(numbers), 6)
Ejemplo n.º 5
0
 def test_phone(self):
     numbers = get_phone(text)
     self.assertEqual(len(numbers), 5)
Ejemplo n.º 6
0
 def test_phone(self):
     numbers = get_phone(text)
     #self.assertEqual(len(numbers), 5)
     # when RE is fixed, all numbers are returned
     self.assertEqual(len(numbers), 6)