Restore previous output after recording

This commit is contained in:
Kovid Goyal 2020-10-22 20:25:54 +05:30
parent a63c21dbfb
commit bfe4260897
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 1 deletions

View File

@ -300,6 +300,7 @@ Voice_create_recording_wav(Voice *self, PyObject *args) {
hr = self->voice->Speak(text.ptr(), SPF_DEFAULT, NULL);
Py_END_ALLOW_THREADS;
stream->Close();
self->voice->SetOutput(uses_default_output ? NULL: token, TRUE);
if (FAILED(hr)) return error_from_hresult(hr, "Failed to speak into wav file", PyTuple_GET_ITEM(args, 0));
Py_RETURN_NONE;
}

View File

@ -65,7 +65,7 @@ def find_tests():
self.assertEqual(self.sapi.get_current_volume(), new_vol)
self.sapi.set_current_volume(dv)
def test_record_as_wav(self):
def test_record_as_audio_file(self):
import tempfile
with tempfile.TemporaryDirectory() as tdir:
wav_path = os.path.join(tdir, 'test.wav')