Skip to content

Commit

Permalink
style: format voice.py and suppress syntax warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-gauthier committed Dec 9, 2024
1 parent e50992b commit cbcbff3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions aider/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -43,7 +45,6 @@ def __init__(self, audio_format="wav", device_name=None):

self.sd = sd


devices = sd.query_devices()

if device_name:
Expand All @@ -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})")

Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit cbcbff3

Please sign in to comment.