refactor: simplify voice command and improve installation docs

This commit is contained in:
Paul Gauthier 2024-12-11 13:52:33 -08:00 committed by Paul Gauthier (aider)
parent fcb2bacd1e
commit f6b956dc8e
5 changed files with 20 additions and 31 deletions

View file

@ -1125,36 +1125,14 @@ class Commands:
)
return
history_iter = self.io.get_input_history()
history = []
size = 0
for line in history_iter:
if line.startswith("/"):
continue
if line in history:
continue
if size + len(line) > 1024:
break
size += len(line)
history.append(line)
history.reverse()
history = "\n".join(history)
try:
text = self.voice.record_and_transcribe(history, language=self.voice_language)
text = self.voice.record_and_transcribe(None, language=self.voice_language)
except litellm.OpenAIError as err:
self.io.tool_error(f"Unable to use OpenAI whisper model: {err}")
return
if text:
self.io.add_to_input_history(text)
self.io.print()
self.io.user_input(text, log_only=False)
self.io.print()
return text
self.io.placeholder = text
def cmd_paste(self, args):
"""Paste image/text from the clipboard into the chat.\