From cbcbff341bac3dcc0b6e6b0bff6c4effa4c71c9d Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 8 Dec 2024 18:14:30 -0800 Subject: [PATCH] style: format voice.py and suppress syntax warnings --- aider/voice.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aider/voice.py b/aider/voice.py index 1e9f700b600..47eddc42b75 100644 --- a/aider/voice.py +++ b/aider/voice.py @@ -14,6 +14,8 @@ warnings.filterwarnings( "ignore", message="Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work" ) +warnings.filterwarnings("ignore", category=SyntaxWarning) + from pydub import AudioSegment # noqa @@ -43,7 +45,6 @@ def __init__(self, audio_format="wav", device_name=None): self.sd = sd - devices = sd.query_devices() if device_name: @@ -55,7 +56,10 @@ def __init__(self, audio_format="wav", device_name=None): break if device_id is None: available_inputs = [d["name"] for d in devices if d["max_input_channels"] > 0] - raise ValueError(f"Device '{device_name}' not found. Available input devices: {available_inputs}") + raise ValueError( + f"Device '{device_name}' not found. Available input devices:" + f" {available_inputs}" + ) print(f"Using input device: {device_name} (ID: {device_id})") @@ -125,7 +129,9 @@ def raw_record_and_transcribe(self, history, language): self.start_time = time.time() try: - with self.sd.InputStream(samplerate=sample_rate, channels=1, callback=self.callback, device=self.device_id): + with self.sd.InputStream( + samplerate=sample_rate, channels=1, callback=self.callback, device=self.device_id + ): prompt(self.get_prompt, refresh_interval=0.1) except self.sd.PortAudioError as err: raise SoundDeviceError(f"Error accessing audio input device: {err}")