mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09: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:
|
try:
|
||||||
self.voice = voice.Voice()
|
self.voice = voice.Voice()
|
||||||
except voice.SoundDeviceError:
|
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
|
return
|
||||||
|
|
||||||
history_iter = self.io.get_input_history()
|
history_iter = self.io.get_input_history()
|
||||||
|
|
|
@ -5,7 +5,12 @@ import time
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import openai
|
import openai
|
||||||
import soundfile as sf
|
|
||||||
|
try:
|
||||||
|
import soundfile as sf
|
||||||
|
except (OSError, ModuleNotFoundError):
|
||||||
|
sf = None
|
||||||
|
|
||||||
from prompt_toolkit.shortcuts import prompt
|
from prompt_toolkit.shortcuts import prompt
|
||||||
|
|
||||||
from .dump import dump # noqa: F401
|
from .dump import dump # noqa: F401
|
||||||
|
@ -23,12 +28,14 @@ class Voice:
|
||||||
threshold = 0.15
|
threshold = 0.15
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
if sf is None:
|
||||||
|
raise SoundDeviceError
|
||||||
try:
|
try:
|
||||||
print("Initializing sound device...")
|
print("Initializing sound device...")
|
||||||
import sounddevice as sd
|
import sounddevice as sd
|
||||||
|
|
||||||
self.sd = sd
|
self.sd = sd
|
||||||
except OSError:
|
except (OSError, ModuleNotFoundError):
|
||||||
raise SoundDeviceError
|
raise SoundDeviceError
|
||||||
|
|
||||||
def callback(self, indata, frames, time, status):
|
def callback(self, indata, frames, time, status):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue