mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
gracefully handle missing portaudio
This commit is contained in:
parent
fed24aa444
commit
7b993a9bbb
2 changed files with 16 additions and 4 deletions
|
@ -8,8 +8,7 @@ import git
|
|||
import tiktoken
|
||||
from prompt_toolkit.completion import Completion
|
||||
|
||||
from aider import prompts
|
||||
from aider.voice import record_and_transcribe
|
||||
from aider import prompts, voice
|
||||
|
||||
from .dump import dump # noqa: F401
|
||||
|
||||
|
@ -437,7 +436,11 @@ class Commands:
|
|||
|
||||
def cmd_voice(self, args):
|
||||
"Record and transcribe voice input"
|
||||
text = record_and_transcribe()
|
||||
if not voice.is_audio_available():
|
||||
self.io.tool_error("Unable to import `sounddevice`, is portaudio installed?")
|
||||
return
|
||||
|
||||
text = voice.record_and_transcribe()
|
||||
self.io.user_input(text, log_only=False)
|
||||
return text
|
||||
|
||||
|
|
|
@ -3,12 +3,21 @@ import queue
|
|||
import tempfile
|
||||
|
||||
import openai
|
||||
import sounddevice as sd
|
||||
|
||||
try:
|
||||
import sounddevice as sd
|
||||
except OSError:
|
||||
sd = None
|
||||
|
||||
import soundfile as sf
|
||||
|
||||
from .dump import dump # noqa: F401
|
||||
|
||||
|
||||
def is_audio_available():
|
||||
return sd is not None
|
||||
|
||||
|
||||
def record_and_transcribe():
|
||||
q = queue.Queue()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue