mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
write .wav in background
This commit is contained in:
parent
93eccd183f
commit
e7d9056acd
1 changed files with 18 additions and 13 deletions
|
@ -612,6 +612,7 @@ class QtAudioInputRecorder(Recorder):
|
||||||
showWarning(f"recording failed: {err}")
|
showWarning(f"recording failed: {err}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def write_file():
|
||||||
# swallow the first 300ms to allow audio device to quiesce
|
# swallow the first 300ms to allow audio device to quiesce
|
||||||
wait = int(44100 * self.STARTUP_DELAY)
|
wait = int(44100 * self.STARTUP_DELAY)
|
||||||
if len(self._buffer) <= wait:
|
if len(self._buffer) <= wait:
|
||||||
|
@ -626,7 +627,11 @@ class QtAudioInputRecorder(Recorder):
|
||||||
wf.writeframes(self._buffer)
|
wf.writeframes(self._buffer)
|
||||||
wf.close()
|
wf.close()
|
||||||
|
|
||||||
super().stop(on_done)
|
def and_then(fut):
|
||||||
|
fut.result()
|
||||||
|
Recorder.stop(self, on_done)
|
||||||
|
|
||||||
|
self.mw.taskman.run_in_background(write_file, and_then)
|
||||||
|
|
||||||
|
|
||||||
# PyAudio recording
|
# PyAudio recording
|
||||||
|
|
Loading…
Reference in a new issue