about summary refs log tree commit diff
path: root/pkgs/development/python-modules/phonemizer
diff options
context:
space:
mode:
authorMartin Weinelt <hexa@darmstadt.ccc.de>2020-06-08 16:27:01 +0200
committerMartin Weinelt <hexa@darmstadt.ccc.de>2020-11-14 17:52:19 +0100
commit8578fb314495b24e1bb3b533d18542459f6031c3 (patch)
treeb13f9694f761ed77941e93de1a68102db9d717ac /pkgs/development/python-modules/phonemizer
parenteb64d1518f08dc580780dcf179306606727548cd (diff)
phonemizer: init at 2.2.1
Diffstat (limited to 'pkgs/development/python-modules/phonemizer')
-rw-r--r--pkgs/development/python-modules/phonemizer/backend-paths.patch29
-rw-r--r--pkgs/development/python-modules/phonemizer/default.nix73
-rw-r--r--pkgs/development/python-modules/phonemizer/drop-readme-festival-test.patch12
-rw-r--r--pkgs/development/python-modules/phonemizer/remove-intertwined-festival-test.patch22
4 files changed, 136 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/phonemizer/backend-paths.patch b/pkgs/development/python-modules/phonemizer/backend-paths.patch
new file mode 100644
index 0000000000000..1734addb0ef1d
--- /dev/null
+++ b/pkgs/development/python-modules/phonemizer/backend-paths.patch
@@ -0,0 +1,29 @@
+diff --git a/phonemizer/backend/espeak.py b/phonemizer/backend/espeak.py
+index 387c11c..ceb5e7e 100644
+--- a/phonemizer/backend/espeak.py
++++ b/phonemizer/backend/espeak.py
+@@ -81,10 +81,7 @@ class BaseEspeakBackend(BaseBackend):
+         if _ESPEAK_DEFAULT_PATH:
+             return _ESPEAK_DEFAULT_PATH
+ 
+-        espeak = distutils.spawn.find_executable('espeak-ng')
+-        if not espeak:  # pragma: nocover
+-            espeak = distutils.spawn.find_executable('espeak')
+-        return espeak
++        return "@espeak@"
+ 
+     @classmethod
+     def is_available(cls):
+diff --git a/phonemizer/backend/festival.py b/phonemizer/backend/festival.py
+index b5bc56d..0833160 100644
+--- a/phonemizer/backend/festival.py
++++ b/phonemizer/backend/festival.py
+@@ -78,7 +78,7 @@ class FestivalBackend(BaseBackend):
+         if _FESTIVAL_DEFAULT_PATH:
+             return _FESTIVAL_DEFAULT_PATH
+ 
+-        return distutils.spawn.find_executable('festival')
++        return "@festival@"
+ 
+     @classmethod
+     def is_available(cls):
diff --git a/pkgs/development/python-modules/phonemizer/default.nix b/pkgs/development/python-modules/phonemizer/default.nix
new file mode 100644
index 0000000000000..2d6531794313c
--- /dev/null
+++ b/pkgs/development/python-modules/phonemizer/default.nix
@@ -0,0 +1,73 @@
+{ lib
+, substituteAll
+, buildPythonApplication
+, fetchPypi
+, python3Packages
+, pkgs
+, joblib
+, segments
+, attrs
+, espeak-ng
+, pytestCheckHook
+, pytestrunner
+, pytestcov
+}:
+
+buildPythonApplication rec {
+  pname = "phonemizer";
+  version = "2.2.1";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "127n4f10zxq60qd8xvlc1amji4wbghqb90rfp25rzdk716kvgwab";
+  };
+
+  postPatch = ''
+    sed -i -e '/\'pytest-runner\'/d setup.py
+  '';
+
+  patches = [
+    (substituteAll {
+      src = ./backend-paths.patch;
+      espeak = "${lib.getBin espeak-ng}/bin/espeak";
+      # override festival path should you try to integrate it
+      festival = "";
+    })
+    ./remove-intertwined-festival-test.patch
+  ];
+
+  propagatedBuildInputs = [
+    joblib
+    segments
+    attrs
+  ];
+
+  preCheck = ''
+    export HOME=$TMPDIR
+  '';
+
+  checkInputs = [
+    pytestCheckHook
+    pytestcov
+  ];
+
+  # We tried to package festvial, but were unable to get the backend running,
+  # so let's disable related tests.
+  pytestFlagsArray = [
+    "--ignore=test/test_festival.py"
+  ];
+
+  disabledTests = [
+    "test_festival"
+    "test_relative"
+    "test_absolute"
+    "test_readme_festival_syll"
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/bootphon/phonemizer";
+    description = "Simple text to phones converter for multiple languages";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ hexa ];
+  };
+}
diff --git a/pkgs/development/python-modules/phonemizer/drop-readme-festival-test.patch b/pkgs/development/python-modules/phonemizer/drop-readme-festival-test.patch
new file mode 100644
index 0000000000000..a60cdf2645a5f
--- /dev/null
+++ b/pkgs/development/python-modules/phonemizer/drop-readme-festival-test.patch
@@ -0,0 +1,12 @@
+diff --git a/test/test_main.py b/test/test_main.py
+index 71d605a..d137cd7 100644
+--- a/test/test_main.py
++++ b/test/test_main.py
+@@ -63,7 +63,6 @@ def test_readme():
+     _test(u'hello world', u'həloʊ wɜːld ')
+     _test(u'hello world', u'həloʊ wɜːld ', '--verbose')
+     _test(u'hello world', u'həloʊ wɜːld ', '--quiet')
+-    _test(u'hello world', u'hhaxlow werld', '-b festival --strip')
+     _test(u'hello world', u'həloʊ wɜːld ', '-l en-us')
+     _test(u'bonjour le monde', u'bɔ̃ʒuʁ lə mɔ̃d ', '-l fr-fr')
+     _test(u'bonjour le monde', u'b ɔ̃ ʒ u ʁ ;eword l ə ;eword m ɔ̃ d ;eword ',
diff --git a/pkgs/development/python-modules/phonemizer/remove-intertwined-festival-test.patch b/pkgs/development/python-modules/phonemizer/remove-intertwined-festival-test.patch
new file mode 100644
index 0000000000000..d7d605df7f986
--- /dev/null
+++ b/pkgs/development/python-modules/phonemizer/remove-intertwined-festival-test.patch
@@ -0,0 +1,22 @@
+diff --git a/test/test_main.py b/test/test_main.py
+index 71d605a..0ea3c74 100644
+--- a/test/test_main.py
++++ b/test/test_main.py
+@@ -63,17 +63,12 @@ def test_readme():
+     _test(u'hello world', u'həloʊ wɜːld ')
+     _test(u'hello world', u'həloʊ wɜːld ', '--verbose')
+     _test(u'hello world', u'həloʊ wɜːld ', '--quiet')
+-    _test(u'hello world', u'hhaxlow werld', '-b festival --strip')
+     _test(u'hello world', u'həloʊ wɜːld ', '-l en-us')
+     _test(u'bonjour le monde', u'bɔ̃ʒuʁ lə mɔ̃d ', '-l fr-fr')
+     _test(u'bonjour le monde', u'b ɔ̃ ʒ u ʁ ;eword l ə ;eword m ɔ̃ d ;eword ',
+           '-l fr-fr -p " " -w ";eword "')
+ 
+ 
+-@pytest.mark.skipif(
+-    '2.1' in backend.FestivalBackend.version(),
+-    reason='festival-2.1 gives different results than further versions '
+-    'for syllable boundaries')
+ def test_readme_festival_syll():
+     _test(u'hello world',
+           u'hh ax ;esyll l ow ;esyll ;eword w er l d ;esyll ;eword ',