mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
disable /voice if import soundfile failes #274
This commit is contained in:
parent
87fb6c8fbb
commit
22eb344192
2 changed files with 12 additions and 3 deletions
|
@ -457,7 +457,9 @@ class Commands:
|
|||
try:
|
||||
self.voice = voice.Voice()
|
||||
except voice.SoundDeviceError:
|
||||
self.io.tool_error("Unable to import `sounddevice`, is portaudio installed?")
|
||||
self.io.tool_error(
|
||||
"Unable to import `sounddevice` and/or `soundfile`, is portaudio installed?"
|
||||
)
|
||||
return
|
||||
|
||||
history_iter = self.io.get_input_history()
|
||||
|
|
|
@ -5,7 +5,12 @@ import time
|
|||
|
||||
import numpy as np
|
||||
import openai
|
||||
import soundfile as sf
|
||||
|
||||
try:
|
||||
import soundfile as sf
|
||||
except (OSError, ModuleNotFoundError):
|
||||
sf = None
|
||||
|
||||
from prompt_toolkit.shortcuts import prompt
|
||||
|
||||
from .dump import dump # noqa: F401
|
||||
|
@ -23,12 +28,14 @@ class Voice:
|
|||
threshold = 0.15
|
||||
|
||||
def __init__(self):
|
||||
if sf is None:
|
||||
raise SoundDeviceError
|
||||
try:
|
||||
print("Initializing sound device...")
|
||||
import sounddevice as sd
|
||||
|
||||
self.sd = sd
|
||||
except OSError:
|
||||
except (OSError, ModuleNotFoundError):
|
||||
raise SoundDeviceError
|
||||
|
||||
def callback(self, indata, frames, time, status):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue