diff --git a/aider/io.py b/aider/io.py index 5dbcc9264..14a499fca 100644 --- a/aider/io.py +++ b/aider/io.py @@ -232,7 +232,6 @@ class InputOutput: return inp def user_input(self, inp, log_only=True): - if not log_only: style = dict(style=self.user_input_color) if self.user_input_color else dict() self.console.print(inp, **style) diff --git a/aider/voice.py b/aider/voice.py index 154cad01f..e4fcc57f4 100644 --- a/aider/voice.py +++ b/aider/voice.py @@ -1,45 +1,41 @@ -import sounddevice as sd -import numpy as np -import keyboard -import openai -import io -import tempfile -import queue -import soundfile as sf import os +import queue +import tempfile + +import openai +import sounddevice as sd +import soundfile as sf + +from .dump import dump # noqa: F401 -from .dump import dump def record_and_transcribe(): - q = queue.Queue() def callback(indata, frames, time, status): """This is called (from a separate thread) for each audio block.""" - if status: - print(status, file=sys.stderr) q.put(indata.copy()) - - filename = tempfile.mktemp(prefix='delme_rec_unlimited_', suffix='.wav', dir='') + filename = tempfile.mktemp(prefix="delme_rec_unlimited_", suffix=".wav", dir="") sample_rate = 16000 # 16kHz - with sf.SoundFile(filename, mode='x', samplerate=sample_rate, channels=1) as file: + with sf.SoundFile(filename, mode="x", samplerate=sample_rate, channels=1) as file: with sd.InputStream(samplerate=sample_rate, channels=1, callback=callback): - input('Press ENTER when done speaking...') + input("Press ENTER when done speaking...") while not q.empty(): file.write(q.get()) - with open(filename, 'rb') as fh: + with open(filename, "rb") as fh: transcript = openai.Audio.transcribe("whisper-1", fh) - text = transcript['text'] + text = transcript["text"] return text + if __name__ == "__main__": - api_key = os.getenv('OPENAI_API_KEY') + api_key = os.getenv("OPENAI_API_KEY") if not api_key: raise ValueError("Please set the OPENAI_API_KEY environment variable.") print(record_and_transcribe()) diff --git a/tests/test_coder.py b/tests/test_coder.py index 9f37dc022..1c2eaa8b2 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -29,7 +29,7 @@ class TestCoder(unittest.TestCase): io = InputOutput(yes=True) # Initialize the Coder object with the mocked IO and mocked repo - coder = Coder.create(models.GPT4, None, io, fnames=[str(fname)]) + Coder.create(models.GPT4, None, io, fnames=[str(fname)]) self.assertTrue(fname.exists()) @@ -40,7 +40,6 @@ class TestCoder(unittest.TestCase): # Check that the latest commit message is "I added str(fname)" self.assertEqual(commit_message, f"I added {str(fname)}") - def test_allowed_to_edit(self): with GitTemporaryDirectory(): repo = git.Repo(Path.cwd())