forgot the sync function

This commit is contained in:
Kovid Goyal 2020-11-13 12:53:54 +05:30
parent e30843221c
commit d851f1bb00
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -117,15 +117,31 @@ cancel(PyObject *self, PyObject *args) {
static PyObject* static PyObject*
is_playing(PyObject *self, PyObject *args) { 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 {{{ // Boilerplate {{{
#define M(name, args, doc) { #name, (PyCFunction)name, args, ""} #define M(name, args, doc) { #name, (PyCFunction)name, args, ""}
static PyMethodDef methods[] = { static PyMethodDef methods[] = {
M(info, METH_NOARGS, "version and path"), M(info, METH_NOARGS, "version and path"),
M(cancel, METH_NOARGS, "cancel all ongoing speech activity"), 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(is_playing, METH_NOARGS, "True iff speech is happening"),
M(list_voices, METH_VARARGS | METH_KEYWORDS, "list available voices"), M(list_voices, METH_VARARGS | METH_KEYWORDS, "list available voices"),
M(set_voice_by_properties, METH_VARARGS | METH_KEYWORDS, "set voice by properties"), M(set_voice_by_properties, METH_VARARGS | METH_KEYWORDS, "set voice by properties"),