mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
lint
This commit is contained in:
parent
ec91eb670e
commit
fed24aa444
3 changed files with 16 additions and 22 deletions
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue