Skip to content

Commit 3e0da73

Browse files
authored
autopep8 (#33)
authored-by: jarbasai <jarbasai@mailfence.com>
1 parent 36ef76b commit 3e0da73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+189
-176
lines changed

mycroft/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import mycroft.configuration
1717
from mycroft.api import Api
1818
from mycroft.messagebus.message import Message
19+
1920
# don't require adapt to be installed to import non-skill stuff
2021
try:
2122
from mycroft.skills.context import adds_context, removes_context

mycroft/api/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from mycroft.version import VersionManager
2525
from mycroft.util import get_arch, connected, LOG
2626

27-
2827
_paired_cache = False
2928

3029

@@ -167,9 +166,10 @@ def get_response(self, response, no_refresh=False):
167166

168167
if 200 <= response.status_code < 300:
169168
return data
170-
elif (not no_refresh and response.status_code == 401 and not
171-
response.url.endswith("auth/token") and
172-
self.identity.is_expired()):
169+
elif all([not no_refresh,
170+
response.status_code == 401,
171+
not response.url.endswith("auth/token"),
172+
self.identity.is_expired()]):
173173
self.refresh_token()
174174
return self.send(self.old_params, no_refresh=True)
175175
raise HTTPError(data, response=response)
@@ -419,7 +419,7 @@ def upload_skills_data(self, data):
419419
"method": "PUT",
420420
"path": "/" + UUID + "/skillJson",
421421
"json": to_send
422-
})
422+
})
423423

424424

425425
class STTApi(Api):

mycroft/audio/services/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from ovos_plugin_manager.templates.audio import AudioBackend, RemoteAudioBackend
2-

mycroft/audio/speech.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from mycroft.util.log import LOG
2424
from mycroft.messagebus.message import Message
2525
from mycroft.tts.remote_tts import RemoteTTSException
26+
2627
try:
2728
from ovos_tts_plugin_mimic import MimicTTSPlugin
2829
except ImportError:

mycroft/client/enclosure/generic/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
"""
1010

1111
from mycroft.client.enclosure.base import Enclosure as EnclosureGeneric
12-

mycroft/client/enclosure/mark1/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from queue import Queue
5050
from mycroft.util.file_utils import get_temp_path
5151

52+
5253
# The Mark 1 hardware consists of a Raspberry Pi main CPU which is connected
5354
# to an Arduino over the serial port. A custom serial protocol sends
5455
# commands to control various visual elements which are controlled by the

mycroft/client/speech/data_structures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class RollingMean:
2424
Args:
2525
mean_samples: Number of samples to use for mean value
2626
"""
27+
2728
def __init__(self, mean_samples):
2829
self.num_samples = mean_samples
2930
self.samples = []
@@ -70,13 +71,14 @@ class CyclicAudioBuffer:
7071
size (int): size in bytes
7172
initial_data (bytes): initial buffer data
7273
"""
74+
7375
def __init__(self, size, initial_data):
7476
self.size = size
7577
# Get at most size bytes from the end of the initial data
7678
self._buffer = initial_data[-size:]
7779

7880
def clear(self):
79-
self._buffer = b'\0' * self.size
81+
self._buffer = b'\0' * self.size
8082

8183
def append(self, data):
8284
"""Add new data to the buffer, and slide out data if the buffer is full

mycroft/client/speech/listener.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,21 @@
1414
#
1515
import time
1616
from threading import Thread
17-
import speech_recognition as sr
1817
import pyaudio
1918
from pyee import EventEmitter
20-
from requests import RequestException
21-
from requests.exceptions import ConnectionError
22-
23-
from mycroft import dialog
2419
from mycroft.client.speech.hotword_factory import HotWordFactory
2520
from mycroft.client.speech.mic import MutableMicrophone, ResponsiveRecognizer
2621
from mycroft.configuration import Configuration
27-
from mycroft.metrics import MetricsAggregator, Stopwatch, report_timing
22+
from mycroft.metrics import Stopwatch, report_timing
2823
from mycroft.session import SessionManager
2924
from mycroft.stt import STTFactory
30-
from mycroft.util import connected
3125
from mycroft.util.log import LOG
3226
from mycroft.util import find_input_device
3327
from queue import Queue, Empty
3428
import json
35-
from copy import deepcopy
36-
3729

3830
MAX_MIC_RESTARTS = 20
3931

40-
4132
AUDIO_DATA = 0
4233
STREAM_START = 1
4334
STREAM_DATA = 2
@@ -167,7 +158,7 @@ def read(self):
167158
@staticmethod
168159
def _audio_length(audio):
169160
return float(len(audio.frame_data)) / (
170-
audio.sample_rate * audio.sample_width)
161+
audio.sample_rate * audio.sample_width)
171162

172163
def process(self, audio, lang=None):
173164
if audio is None:
@@ -281,7 +272,7 @@ def _load_config(self):
281272
if not device_index and device_name:
282273
device_index = find_input_device(device_name)
283274

284-
LOG.debug('Using microphone (None = default): '+str(device_index))
275+
LOG.debug('Using microphone (None = default): ' + str(device_index))
285276

286277
self.microphone = MutableMicrophone(device_index, rate,
287278
mute=self.mute_calls > 0)

mycroft/client/speech/mic.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
CyclicAudioBuffer
5050
from mycroft.util import resolve_resource_file
5151

52-
5352
WakeWordData = namedtuple('WakeWordData',
5453
['audio', 'found', 'stopped', 'end_audio'])
5554

@@ -223,6 +222,7 @@ class NoiseTracker:
223222
silence_after_loud (float): time of silence to finalize the sentence.
224223
default 0.25 seconds.
225224
"""
225+
226226
def __init__(self, minimum, maximum, sec_per_buffer, loud_time_limit,
227227
silence_time_limit, silence_after_loud_time=0.25):
228228
self.min_level = minimum
@@ -439,11 +439,11 @@ def check_for_hotwords(self, audio_data):
439439
yield ww
440440

441441
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
447447
):
448448
"""Record an entire spoken phrase.
449449
@@ -517,7 +517,7 @@ def write_mic_level(self, energy, source):
517517
energy,
518518
self.energy_threshold,
519519
int(source.muted)
520-
)
520+
)
521521
)
522522

523523
def _skip_wake_word(self):
@@ -718,7 +718,7 @@ def _wait_until_wake_word(self, source, sec_per_buffer):
718718
while not said_wake_word and not self._stop_signaled:
719719
if self._skip_wake_word():
720720
return WakeWordData(audio_data, False,
721-
self._stop_signaled, ww_frames), \
721+
self._stop_signaled, ww_frames), \
722722
self.config.get("lang", "en-us")
723723
chunk = self.record_sound_chunk(source)
724724
audio_buffer.append(chunk)
@@ -754,7 +754,7 @@ def _wait_until_wake_word(self, source, sec_per_buffer):
754754
self._handle_hotword_found(hotword, audio_data, source)
755755
if listen and not self.loop.state.sleeping:
756756
return WakeWordData(audio_data, said_wake_word,
757-
self._stop_signaled, ww_frames), stt_lang
757+
self._stop_signaled, ww_frames), stt_lang
758758

759759
if said_hot_word:
760760
# reset bytearray to store wake word audio in, else many
@@ -834,8 +834,8 @@ def _adjust_threshold(self, energy, seconds_per_buffer):
834834
if self.dynamic_energy_threshold and energy > 0:
835835
# account for different chunk sizes and rates
836836
damping = (
837-
self.dynamic_energy_adjustment_damping ** seconds_per_buffer)
837+
self.dynamic_energy_adjustment_damping ** seconds_per_buffer)
838838
target_energy = energy * self.energy_ratio
839839
self.energy_threshold = (
840-
self.energy_threshold * damping +
841-
target_energy * (1 - damping))
840+
self.energy_threshold * damping +
841+
target_energy * (1 - damping))

mycroft/client/text/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import curses
2020
from mycroft.util import get_ipc_directory
2121
from mycroft.client.text.text_client import (
22-
load_settings, save_settings, simple_cli, gui_main,
23-
start_log_monitor, start_mic_monitor, connect_to_mycroft,
24-
ctrl_c_handler
25-
)
22+
load_settings, save_settings, simple_cli, gui_main,
23+
start_log_monitor, start_mic_monitor, connect_to_mycroft,
24+
ctrl_c_handler
25+
)
2626
from mycroft.configuration import Configuration, setup_locale
2727

2828
sys.stdout = io.StringIO()

0 commit comments

Comments
 (0)