diff --git a/anki/sound.py b/anki/sound.py index d41ea8f8e..aa3431b14 100644 --- a/anki/sound.py +++ b/anki/sound.py @@ -334,13 +334,16 @@ class _Recorder: except: ret = True finally: - if os.path.exists(processingSrc): - os.unlink(processingSrc) + self.cleanup() if ret: raise Exception(_( "Error running %s") % " ".join(cmd)) + def cleanup(self): + if os.path.exists(processingSrc): + os.unlink(processingSrc) + class PyAudioThreadedRecorder(threading.Thread): def __init__(self, startupDelay): diff --git a/aqt/sound.py b/aqt/sound.py index 2ca97be6e..0bcf70cc6 100644 --- a/aqt/sound.py +++ b/aqt/sound.py @@ -40,6 +40,7 @@ def getAudio(parent, encode=True): QApplication.instance().processEvents() if mb.clickedButton() == mb.escapeButton(): r.stop() + r.cleanup() return saveGeom(mb, "audioRecorder") # ensure at least a second captured