|
49 | 49 | CyclicAudioBuffer |
50 | 50 | from mycroft.util import resolve_resource_file |
51 | 51 |
|
52 | | - |
53 | 52 | WakeWordData = namedtuple('WakeWordData', |
54 | 53 | ['audio', 'found', 'stopped', 'end_audio']) |
55 | 54 |
|
@@ -223,6 +222,7 @@ class NoiseTracker: |
223 | 222 | silence_after_loud (float): time of silence to finalize the sentence. |
224 | 223 | default 0.25 seconds. |
225 | 224 | """ |
| 225 | + |
226 | 226 | def __init__(self, minimum, maximum, sec_per_buffer, loud_time_limit, |
227 | 227 | silence_time_limit, silence_after_loud_time=0.25): |
228 | 228 | self.min_level = minimum |
@@ -439,11 +439,11 @@ def check_for_hotwords(self, audio_data): |
439 | 439 | yield ww |
440 | 440 |
|
441 | 441 | def _record_phrase( |
442 | | - self, |
443 | | - source, |
444 | | - sec_per_buffer, |
445 | | - stream=None, |
446 | | - ww_frames=None |
| 442 | + self, |
| 443 | + source, |
| 444 | + sec_per_buffer, |
| 445 | + stream=None, |
| 446 | + ww_frames=None |
447 | 447 | ): |
448 | 448 | """Record an entire spoken phrase. |
449 | 449 |
|
@@ -517,7 +517,7 @@ def write_mic_level(self, energy, source): |
517 | 517 | energy, |
518 | 518 | self.energy_threshold, |
519 | 519 | int(source.muted) |
520 | | - ) |
| 520 | + ) |
521 | 521 | ) |
522 | 522 |
|
523 | 523 | def _skip_wake_word(self): |
@@ -718,7 +718,7 @@ def _wait_until_wake_word(self, source, sec_per_buffer): |
718 | 718 | while not said_wake_word and not self._stop_signaled: |
719 | 719 | if self._skip_wake_word(): |
720 | 720 | return WakeWordData(audio_data, False, |
721 | | - self._stop_signaled, ww_frames), \ |
| 721 | + self._stop_signaled, ww_frames), \ |
722 | 722 | self.config.get("lang", "en-us") |
723 | 723 | chunk = self.record_sound_chunk(source) |
724 | 724 | audio_buffer.append(chunk) |
@@ -754,7 +754,7 @@ def _wait_until_wake_word(self, source, sec_per_buffer): |
754 | 754 | self._handle_hotword_found(hotword, audio_data, source) |
755 | 755 | if listen and not self.loop.state.sleeping: |
756 | 756 | return WakeWordData(audio_data, said_wake_word, |
757 | | - self._stop_signaled, ww_frames), stt_lang |
| 757 | + self._stop_signaled, ww_frames), stt_lang |
758 | 758 |
|
759 | 759 | if said_hot_word: |
760 | 760 | # reset bytearray to store wake word audio in, else many |
@@ -834,8 +834,8 @@ def _adjust_threshold(self, energy, seconds_per_buffer): |
834 | 834 | if self.dynamic_energy_threshold and energy > 0: |
835 | 835 | # account for different chunk sizes and rates |
836 | 836 | damping = ( |
837 | | - self.dynamic_energy_adjustment_damping ** seconds_per_buffer) |
| 837 | + self.dynamic_energy_adjustment_damping ** seconds_per_buffer) |
838 | 838 | target_energy = energy * self.energy_ratio |
839 | 839 | self.energy_threshold = ( |
840 | | - self.energy_threshold * damping + |
841 | | - target_energy * (1 - damping)) |
| 840 | + self.energy_threshold * damping + |
| 841 | + target_energy * (1 - damping)) |
0 commit comments