From d851f1bb00b531110d88d22465f2048e1a4f9d4d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 13 Nov 2020 12:53:54 +0530 Subject: [PATCH] forgot the sync function --- src/calibre/utils/tts/espeak.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/tts/espeak.cpp b/src/calibre/utils/tts/espeak.cpp index 69249775d7..1dfac65617 100644 --- a/src/calibre/utils/tts/espeak.cpp +++ b/src/calibre/utils/tts/espeak.cpp @@ -117,15 +117,31 @@ cancel(PyObject *self, PyObject *args) { static PyObject* is_playing(PyObject *self, PyObject *args) { - return Py_BuildValue("O", espeak_IsPlaying() ? Py_True : Py_False); + int ans; + Py_BEGIN_ALLOW_THREADS + ans = espeak_IsPlaying(); + Py_END_ALLOW_THREADS + return Py_BuildValue("O", ans ? Py_True : Py_False); } +static PyObject* +synchronize(PyObject *self, PyObject *args) { + espeak_ERROR err; + Py_BEGIN_ALLOW_THREADS; + err = espeak_Synchronize(); + Py_END_ALLOW_THREADS; + if (err != EE_OK) return espeak_error("Failed to synchronize speech", err); + Py_RETURN_NONE; +} + + // Boilerplate {{{ #define M(name, args, doc) { #name, (PyCFunction)name, args, ""} static PyMethodDef methods[] = { M(info, METH_NOARGS, "version and path"), M(cancel, METH_NOARGS, "cancel all ongoing speech activity"), + M(synchronize, METH_NOARGS, "synchronize all ongoing speech activity"), M(is_playing, METH_NOARGS, "True iff speech is happening"), M(list_voices, METH_VARARGS | METH_KEYWORDS, "list available voices"), M(set_voice_by_properties, METH_VARARGS | METH_KEYWORDS, "set voice by properties"),