mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
Switched voice to litellm
This commit is contained in:
parent
cf2a48b21f
commit
f1c09ececf
2 changed files with 14 additions and 4 deletions
|
@ -1,9 +1,11 @@
|
|||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import git
|
||||
import openai
|
||||
from prompt_toolkit.completion import Completion
|
||||
|
||||
from aider import prompts, voice
|
||||
|
@ -547,8 +549,11 @@ class Commands:
|
|||
"Record and transcribe voice input"
|
||||
|
||||
if not self.voice:
|
||||
if "OPENAI_API_KEY" not in os.environ:
|
||||
self.io.tool_error("To use /voice you must provide an OpenAI API key.")
|
||||
return
|
||||
try:
|
||||
self.voice = voice.Voice(self.coder.client)
|
||||
self.voice = voice.Voice()
|
||||
except voice.SoundDeviceError:
|
||||
self.io.tool_error(
|
||||
"Unable to import `sounddevice` and/or `soundfile`, is portaudio installed?"
|
||||
|
@ -572,7 +577,12 @@ class Commands:
|
|||
history.reverse()
|
||||
history = "\n".join(history)
|
||||
|
||||
try:
|
||||
text = self.voice.record_and_transcribe(history, language=self.voice_language)
|
||||
except openai.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)
|
||||
print()
|
||||
|
|
|
@ -3,6 +3,7 @@ import queue
|
|||
import tempfile
|
||||
import time
|
||||
|
||||
import litellm
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
|
@ -86,9 +87,8 @@ class Voice:
|
|||
while not self.q.empty():
|
||||
file.write(self.q.get())
|
||||
|
||||
# TODO: fix client!
|
||||
with open(filename, "rb") as fh:
|
||||
transcript = self.client.audio.transcriptions.create(
|
||||
transcript = litellm.transcription(
|
||||
model="whisper-1", file=fh, prompt=history, language=language
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue