Exemple #1
0
    def handle_record(self):
        """Handler for starting a recording."""
        # Calculate how long to record
        self.start_time = now_local()
        # Extract time, if missing default to 30 seconds
        if int(self.settings["duration"]) <= 0:
            self.settings["duration"] = 60  # default recording duration

        record_for = nice_duration(self.settings["duration"], lang=self.lang)
        self.start_time = now_local()  # recalc after speaking completes
        try:
            os.remove(self.settings["file_path"])
        except Exception:
            pass
        print('record_for', int(self.settings["duration"]))
        dirname = os.getcwd()
        print('cwd', dirname)
        self.settings['file_path'] = os.path.join(dirname, 'example.wav')
        print('mycroft_recording_path', self.settings['file_path'],
              int(self.settings["duration"]), self.settings["rate"],
              self.settings["channels"])
        self.record_process = record(self.settings['file_path'],
                                     int(self.settings["duration"]),
                                     self.settings["rate"],
                                     self.settings["channels"])
        time.sleep(15)
        self.end_recording()
        print('self.record_process', self.record_process)
 def test_record_without_duration(self, mock_subprocess):
     mock_proc = mock.Mock(name='mock process')
     mock_subprocess.Popen.return_value = mock_proc
     rate = 16000
     channels = 1
     filename = '/tmp/test.wav'
     duration = 0
     res = record(filename, duration, rate, channels)
     mock_subprocess.Popen.assert_called_once_with(['arecord',
                                                    '-r', str(rate),
                                                    '-c', str(channels),
                                                    filename])
     self.assertEqual(res, mock_proc)
Exemple #3
0
 def handle_record(self, message):
     utterance = message.data.get('utterance')
     date = self.get_utc_time(utterance)
     now = self.get_utc_time()
     self.duration = self.get_duration(date, now)
     if self.is_free_disk_space():
         self.notify_time = now
         self.feedback_start()
         time.sleep(3)
         self.record_process = record(
             self.file_path, self.duration, self.rate, self.channels)
         self.schedule()
     else:
         self.speak_dialog("audio.record.disk.full")
Exemple #4
0
 def handle_record(self, message):
     utterance = message.metadata.get('utterance')
     date = self.get_utc_time(utterance)
     now = self.get_utc_time()
     self.duration = self.get_duration(date, now)
     if self.is_free_disk_space():
         self.notify_time = now
         self.feedback_start()
         time.sleep(3)
         self.record_process = record(self.file_path, self.duration,
                                      self.rate, self.channels)
         self.schedule()
     else:
         self.speak_dialog("audio.record.disk.full")
Exemple #5
0
    def handle_record(self, message):
        """Handler for starting a recording."""
        utterance = message.data.get('utterance')

        # Calculate how long to record
        self.start_time = now_local()
        # Extract time, if missing default to 30 seconds
        stop_time, _ = (
            extract_datetime(utterance, lang=self.lang) or
            (now_local() + timedelta(seconds=self.settings["duration"]), None)
        )
        self.settings["duration"] = (stop_time -
                                     self.start_time).total_seconds()
        if self.settings["duration"] <= 0:
            self.settings["duration"] = 60  # default recording duration

        # Throw away any previous recording
        try:
            os.remove(self.settings["file_path"])
        except Exception:
            pass

        if self.has_free_disk_space():
            record_for = nice_duration(self.settings["duration"],
                                       lang=self.lang)
            self.speak_dialog('audio.record.start.duration',
                              {'duration': record_for})

            # Initiate recording
            wait_while_speaking()
            self.start_time = now_local()   # recalc after speaking completes
            self.record_process = record(self.settings["file_path"],
                                         int(self.settings["duration"]),
                                         self.settings["rate"],
                                         self.settings["channels"])
            self.enclosure.eyes_color(255, 0, 0)  # set color red
            self.last_index = 24
            self.schedule_repeating_event(self.recording_feedback, None, 1,
                                          name='RecordingFeedback')
        else:
            self.speak_dialog("audio.record.disk.full")
Exemple #6
0
    def	handle_help(self, message):
	"""
	Record 10 seconds to help_audio_file.mp3 file
    	"""
	self.speak_dialog("push.help")
	time.sleep(7)
	p = play_wav(self.audio_effects+"ding.wav")
	p.communicate()


	r = record(self.help_audio+".wav",10,16000,1)
	r.communicate()

	p = play_wav(self.audio_effects+"dong.wav")
	p.communicate()

	with open(self.help_audio+".wav","rb") as mp3:
	    file_data = self.pb.upload_file(mp3, "help_audio_file.wav")
	chat = self.pb.devices
  	push = self.pb.push_file(**file_data)
	self.speak_dialog("push.help.send")