allow running with pyaudio missing
This commit is contained in:
parent
7f8b4b89ae
commit
ca710ab3f1
@ -297,12 +297,15 @@ addHook("unloadProfile", stopMplayer)
|
||||
# PyAudio recording
|
||||
##########################################################################
|
||||
|
||||
import pyaudio
|
||||
import wave
|
||||
try:
|
||||
import pyaudio
|
||||
import wave
|
||||
|
||||
PYAU_FORMAT = pyaudio.paInt16
|
||||
PYAU_CHANNELS = 1
|
||||
PYAU_INPUT_INDEX = None
|
||||
PYAU_FORMAT = pyaudio.paInt16
|
||||
PYAU_CHANNELS = 1
|
||||
PYAU_INPUT_INDEX = None
|
||||
except:
|
||||
pyaudio = None
|
||||
|
||||
class _Recorder:
|
||||
|
||||
@ -389,6 +392,9 @@ class PyAudioRecorder(_Recorder):
|
||||
else:
|
||||
return processingSrc
|
||||
|
||||
if not pyaudio:
|
||||
PyAudioRecorder = None
|
||||
|
||||
# Audio interface
|
||||
##########################################################################
|
||||
|
||||
|
@ -5,11 +5,18 @@ from aqt.qt import *
|
||||
|
||||
import time
|
||||
from anki.sound import Recorder
|
||||
from aqt.utils import saveGeom, restoreGeom
|
||||
from aqt.utils import saveGeom, restoreGeom, showWarning
|
||||
|
||||
if not Recorder:
|
||||
print("pyaudio not installed")
|
||||
|
||||
def getAudio(parent, encode=True):
|
||||
"Record and return filename"
|
||||
# record first
|
||||
if not Recorder:
|
||||
showWarning("pyaudio not installed")
|
||||
return
|
||||
|
||||
r = Recorder()
|
||||
mb = QMessageBox(parent)
|
||||
restoreGeom(mb, "audioRecorder")
|
||||
|
Loading…
Reference in New Issue
Block a user