allow running with pyaudio missing

This commit is contained in:
Damien Elmes 2019-02-13 09:36:39 +10:00
parent 7f8b4b89ae
commit ca710ab3f1
2 changed files with 19 additions and 6 deletions

View File

@ -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
##########################################################################

View File

@ -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")