Skip to content

Commit

Permalink
allow running with pyaudio missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Feb 12, 2019
1 parent 7f8b4b8 commit ca710ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 11 additions & 5 deletions anki/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,15 @@ def stopMplayer(*args):
# 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:

Expand Down Expand Up @@ -389,6 +392,9 @@ def file(self):
else:
return processingSrc

if not pyaudio:
PyAudioRecorder = None

# Audio interface
##########################################################################

Expand Down
9 changes: 8 additions & 1 deletion aqt/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@

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")
Expand Down

0 comments on commit ca710ab

Please # to comment.