diff --git a/devices/nos/modules/subtitles/syncing/subsync/default.nix b/devices/nos/modules/subtitles/syncing/subsync/default.nix index f7e45d7..f796a14 100644 --- a/devices/nos/modules/subtitles/syncing/subsync/default.nix +++ b/devices/nos/modules/subtitles/syncing/subsync/default.nix @@ -24,8 +24,8 @@ in buildInputs = [ ffmpeg pkg-config - pocketsphinx sphinxbase + pocketsphinx ]; nativeBuildInputs = with python3Packages; [ @@ -45,10 +45,7 @@ in utils ]; - patches = [ - ./patches/cmd_ln.patch - ./patches/cstdint.patch - ]; + patches = [./patches/cstdint.patch]; # The tests are for the GUI doCheck = false; diff --git a/devices/nos/modules/subtitles/syncing/subsync/patches/cmd_ln.patch b/devices/nos/modules/subtitles/syncing/subsync/patches/cmd_ln.patch deleted file mode 100644 index 28011ba..0000000 --- a/devices/nos/modules/subtitles/syncing/subsync/patches/cmd_ln.patch +++ /dev/null @@ -1,65 +0,0 @@ -diff --git a/gizmo/media/speechrec.h b/gizmo/media/speechrec.h -index de7a932..076c8fe 100644 ---- a/gizmo/media/speechrec.h -+++ b/gizmo/media/speechrec.h -@@ -5,6 +5,7 @@ - #include "text/words.h" - #include - #include -+#include - - - class SpeechRecognition : public AVOutput - -diff --git a/gizmo/media/speechrec.cpp b/gizmo/media/speechrec.cpp -index 4fe0bf7..fd041b9 100644 ---- a/gizmo/media/speechrec.cpp -+++ b/gizmo/media/speechrec.cpp -@@ -3,6 +3,7 @@ - #include "general/exception.h" - #include - #include -+#include - - using namespace std; - -@@ -30,28 +31,13 @@ SpeechRecognition::~SpeechRecognition() - - void SpeechRecognition::setParam(const string &key, const string &val) - { -- arg_t const *args = ps_args(); -+ ps_arg_t const *args = ps_args(); - - for (size_t i = 0; args[i].name != NULL; i++) - { - if (key == args[i].name) - { -- int type = args[i].type; -- if (type & ARG_INTEGER) -- cmd_ln_set_int_r(m_config, key.c_str(), atol(val.c_str())); -- else if (type & ARG_FLOATING) -- cmd_ln_set_float_r(m_config, key.c_str(), atof(val.c_str())); -- else if (type & ARG_STRING) -- cmd_ln_set_str_r(m_config, key.c_str(), val.c_str()); -- else if (type & ARG_BOOLEAN) -- cmd_ln_set_boolean_r(m_config, key.c_str(), -- !(val.empty() || val == "0")); -- else -- throw EXCEPTION("invalid parameter type") -- .module("SpeechRecognition", "setParameter") -- .add("parameter", key) -- .add("value", val) -- .add("type", type); -+ cmd_ln_set_str_extra_r(m_config, key.c_str(), val.c_str()); - - return; - } -@@ -89,7 +75,7 @@ void SpeechRecognition::start(const AVStream *stream) - throw EXCEPTION("can't init Sphinx engine") - .module("SpeechRecognition", "ps_init"); - -- int32_t frate = cmd_ln_int32_r(m_config, "-frate"); -+ int32_t frate = ((cmd_ln_access_r(m_config, "-frate"))->val).fl; - m_framePeriod = 1.0 / (double)frate; - - if (frate == 0) diff --git a/devices/nos/modules/subtitles/syncing/subsync/patches/distutils.patch b/devices/nos/modules/subtitles/syncing/subsync/patches/distutils.patch new file mode 100644 index 0000000..ac30051 --- /dev/null +++ b/devices/nos/modules/subtitles/syncing/subsync/patches/distutils.patch @@ -0,0 +1,26 @@ +diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4 +index 59a2ff09..af64eab2 100644 +--- a/m4/ax_python_devel.m4 ++++ b/m4/ax_python_devel.m4 +@@ -132,21 +132,6 @@ variable to configure. See ``configure --help'' for reference. + fi + fi + +- # +- # Check if you have distutils, else fail +- # +- AC_MSG_CHECKING([for the distutils Python package]) +- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` +- if test -z "$ac_distutils_result"; then +- AC_MSG_RESULT([yes]) +- else +- AC_MSG_RESULT([no]) +- AC_MSG_ERROR([cannot import Python module "distutils". +-Please check your Python installation. The error was: +-$ac_distutils_result]) +- PYTHON_VERSION="" +- fi +- + # + # Check for Python include path + # diff --git a/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix b/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix index ce00c1d..10da403 100644 --- a/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix +++ b/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix @@ -1,29 +1,40 @@ { - cmake, + autoreconfHook, + fetchFromGitHub, pkg-config, - pocketsphinx-src, + python3, sphinxbase, stdenv, + swig2, ... -}: let - pyproject = - ( - fromTOML ( - builtins.readFile "${pocketsphinx-src}/pyproject.toml" - ) - ) - .project; -in - stdenv.mkDerivation rec { - name = "pocketsphinx"; - inherit (pyproject) version; +}: +stdenv.mkDerivation { + pname = "pocketsphinx"; + version = "5prealpha"; - src = pocketsphinx-src; + src = fetchFromGitHub { + owner = "cmusphinx"; + repo = "pocketsphinx"; + rev = "5da71f0a05350c923676b02a69423d1291825d5b"; + hash = "sha256-YZwuVYg8Uqt1gOYXeYC8laRj+IObbuO9f/BjcQKRwkY="; + }; - buildInputs = [pkg-config]; - nativeBuildInputs = [cmake sphinxbase]; + patches = [./patches/distutils.patch]; - postFixup = '' - cp -ar ${src}/src/util $out/include - ''; - } + autoreconfPhase = '' + ./autogen.sh + ''; + nativeBuildInputs = [ + autoreconfHook + pkg-config + swig2 + python3 + ]; + propagatedBuildInputs = [ + sphinxbase + ]; + + postFixup = '' + cp $out/include/pocketsphinx/* $out/include + ''; +} diff --git a/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix b/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix index 8db0624..d6ad2a9 100644 --- a/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix +++ b/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix @@ -25,4 +25,8 @@ stdenv.mkDerivation { rev = "617e53691889336a482631380f75b453445d0dae"; hash = "sha256-w/Huz4+crTzdiSyQVAx0h3lhtTTrtPyKp3xpQD5EG9g="; }; + + postFixup = '' + cp $out/include/sphinxbase/* $out/include/ + ''; }