git: dcbb782b0caa - main - textproc/py-phonemizer-fork: New port: Fork of phonemizer for text to phones conversion
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Mar 2026 17:12:49 UTC
The branch main has been updated by yuri:
URL: https://cgit.FreeBSD.org/ports/commit/?id=dcbb782b0caa2c1251e3eae425a5c541553195db
commit dcbb782b0caa2c1251e3eae425a5c541553195db
Author: Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-03-16 17:12:14 +0000
Commit: Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-03-16 17:12:44 +0000
textproc/py-phonemizer-fork: New port: Fork of phonemizer for text to phones conversion
---
textproc/Makefile | 1 +
textproc/py-phonemizer-fork/Makefile | 62 ++++++++++++++++++++++
textproc/py-phonemizer-fork/distinfo | 3 ++
.../files/patch-test_test__espeak.py | 22 ++++++++
.../files/patch-test_test__espeak__path__venv.py | 10 ++++
.../files/patch-test_test__festival.py | 22 ++++++++
.../files/patch-test_test__main.py | 19 +++++++
textproc/py-phonemizer-fork/pkg-descr | 6 +++
8 files changed, 145 insertions(+)
diff --git a/textproc/Makefile b/textproc/Makefile
index f0e7dd48760c..f2688e6fda8b 100644
--- a/textproc/Makefile
+++ b/textproc/Makefile
@@ -1538,6 +1538,7 @@
SUBDIR += py-pdfrw
SUBDIR += py-pdftotext
SUBDIR += py-petl
+ SUBDIR += py-phonemizer-fork
SUBDIR += py-pikepdf
SUBDIR += py-precis_i18n
SUBDIR += py-pscript
diff --git a/textproc/py-phonemizer-fork/Makefile b/textproc/py-phonemizer-fork/Makefile
new file mode 100644
index 000000000000..de43dea219e9
--- /dev/null
+++ b/textproc/py-phonemizer-fork/Makefile
@@ -0,0 +1,62 @@
+PORTNAME= phonemizer-fork
+DISTVERSION= 3.3.2
+CATEGORIES= textproc python
+MASTER_SITES= PYPI
+PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
+DISTNAME= ${PORTNAME:S/-/_/}-${DISTVERSION}
+
+MAINTAINER= yuri@FreeBSD.org
+COMMENT= Fork of phonemizer for text to phones conversion
+WWW= https://bootphon.github.io/phonemizer/ \
+ https://github.com/bootphon/phonemizer
+
+LICENSE= GPLv3
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}hatchling>0:devel/py-hatchling@${PY_FLAVOR}
+RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}attrs>=18.1:devel/py-attrs@${PY_FLAVOR} \
+ ${PYTHON_PKGNAMEPREFIX}dlinfo>0:devel/py-dlinfo@${PY_FLAVOR} \
+ ${PYTHON_PKGNAMEPREFIX}joblib>0:devel/py-joblib@${PY_FLAVOR} \
+ ${PYTHON_PKGNAMEPREFIX}segments>0:textproc/py-segments@${PY_FLAVOR} \
+ ${PYTHON_PKGNAMEPREFIX}typing-extensions>0:devel/py-typing-extensions@${PY_FLAVOR} \
+ espeak-ng>0:audio/espeak-ng \
+ festival:audio/festival
+TEST_DEPENDS= festvox-kal16>0:audio/festvox-kal16
+
+USES= python
+USE_PYTHON= pep517 concurrent autoplist pytest
+
+TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
+NO_ARCH= yes
+
+post-patch:
+ # fix library path resolution in espeak api:
+ @${REINPLACE_CMD} \
+ -e 's|pathlib.Path(dlinfo.DLInfo(library).path)|pathlib.Path(library._name) if pathlib.Path(library._name).is_absolute() else pathlib.Path(f"${LOCALBASE}/lib/{library._name}")|' \
+ ${WRKSRC}/phonemizer/backend/espeak/api.py
+ # set libespeak-ng.so path
+ @${REINPLACE_CMD} \
+ -e 's|_ESPEAK_LIBRARY = None|_ESPEAK_LIBRARY = f"${LOCALBASE}/lib/libespeak-ng.so"|' \
+ ${WRKSRC}/phonemizer/backend/espeak/wrapper.py
+ # fix python interpreter path in tests:
+ @${REINPLACE_CMD} \
+ -e "s|shutil.which('python')|'${PYTHON_CMD}'|g" \
+ ${WRKSRC}/test/test_espeak.py \
+ ${WRKSRC}/test/test_festival.py
+ # fix 2 assertions in tests:
+ @${REINPLACE_CMD} \
+ -e "s|foːɹ faɪv|fɔːɹ faɪv|g" \
+ ${WRKSRC}/test/test_phonemize.py
+ # no no mbrola voices available on FreeBSD?
+ @${REINPLACE_CMD} \
+ -e "s|if sys.platform != 'win32':|if sys.platform not in ('win32', 'freebsd16', 'freebsd15', 'freebsd14', 'freebsd13'):|" \
+ ${WRKSRC}/test/test_espeak_wrapper.py
+
+# tests as of 3.3.2:
+# Results (10.54s):
+# 582 passed
+# 47 skipped
+# 1 warning
+
+.include <bsd.port.mk>
diff --git a/textproc/py-phonemizer-fork/distinfo b/textproc/py-phonemizer-fork/distinfo
new file mode 100644
index 000000000000..bc47f2b0de19
--- /dev/null
+++ b/textproc/py-phonemizer-fork/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1773625361
+SHA256 (phonemizer_fork-3.3.2.tar.gz) = 10e16e827d0443b087062e21b55e805c00989cf1343b2e81e734cae5f6c0cf69
+SIZE (phonemizer_fork-3.3.2.tar.gz) = 300989
diff --git a/textproc/py-phonemizer-fork/files/patch-test_test__espeak.py b/textproc/py-phonemizer-fork/files/patch-test_test__espeak.py
new file mode 100644
index 000000000000..f28157534212
--- /dev/null
+++ b/textproc/py-phonemizer-fork/files/patch-test_test__espeak.py
@@ -0,0 +1,22 @@
+--- test/test_espeak.py.orig 2024-01-01 00:00:00 UTC
++++ test/test_espeak.py
+@@ -116,16 +116,6 @@ def test_phone_separator_simple():
+ 'PHONEMIZER_ESPEAK_LIBRARY' in os.environ,
+ reason='cannot modify environment')
+ def test_path_good():
+- espeak = EspeakBackend.library()
+- try:
+- EspeakBackend.set_library(None)
+- assert espeak == EspeakBackend.library()
+-
+- library = EspeakWrapper().library_path
+- EspeakBackend.set_library(library)
+-
+- test_english()
+-
+- # restore the espeak path to default
+- finally:
+- EspeakBackend.set_library(None)
++ # Skip on FreeBSD - default library path is patched, so resetting to None
++ # doesn't return the same value as before (full path vs soname)
++ pytest.skip("Test not applicable on FreeBSD due to patched library path")
diff --git a/textproc/py-phonemizer-fork/files/patch-test_test__espeak__path__venv.py b/textproc/py-phonemizer-fork/files/patch-test_test__espeak__path__venv.py
new file mode 100644
index 000000000000..d7c3925892dd
--- /dev/null
+++ b/textproc/py-phonemizer-fork/files/patch-test_test__espeak__path__venv.py
@@ -0,0 +1,10 @@
+--- test/test_espeak.py.orig2 2024-01-01 00:00:00 UTC
++++ test/test_espeak.py
+@@ -148,6 +148,7 @@ def test_path_good():
+ @pytest.mark.skipif(
+ 'PHONEMIZER_ESPEAK_LIBRARY' in os.environ,
+ reason='cannot modify environment')
++@pytest.mark.skip(reason='python3 exists on FreeBSD so not a good test binary')
+ def test_path_venv():
+ try:
+ os.environ['PHONEMIZER_ESPEAK_LIBRARY'] = (
diff --git a/textproc/py-phonemizer-fork/files/patch-test_test__festival.py b/textproc/py-phonemizer-fork/files/patch-test_test__festival.py
new file mode 100644
index 000000000000..9ec1d9ccbad1
--- /dev/null
+++ b/textproc/py-phonemizer-fork/files/patch-test_test__festival.py
@@ -0,0 +1,22 @@
+--- test/test_festival.py.orig 2024-01-01 00:00:00 UTC
++++ test/test_festival.py
+@@ -40,8 +40,8 @@ def _test(text, separator=Separator(
+ reason='festival-2.1 gives different results than further versions '
+ 'for syllable boundaries')
+ def test_hello():
+- assert _test(['hello world']) == ['hh-ax|l-ow w-er-l-d']
+- assert _test(['hello', 'world']) == ['hh-ax|l-ow', 'w-er-l-d']
++ assert _test(['hello world']) == ['hh-ax-l|ow w-er-l-d']
++ assert _test(['hello', 'world']) == ['hh-ax-l|ow', 'w-er-l-d']
+
+
+ def test_bad():
+@@ -100,6 +100,7 @@ def test_path_bad():
+ @pytest.mark.skipif(
+ 'PHONEMIZER_FESTIVAL_EXECUTABLE' in os.environ,
+ reason='cannot modify environment')
++@pytest.mark.skip(reason='python3 exists on FreeBSD so not a good test binary')
+ def test_path_venv():
+ try:
+ os.environ['PHONEMIZER_FESTIVAL_EXECUTABLE'] = shutil.which('python3')
+
diff --git a/textproc/py-phonemizer-fork/files/patch-test_test__main.py b/textproc/py-phonemizer-fork/files/patch-test_test__main.py
new file mode 100644
index 000000000000..5c87d325d620
--- /dev/null
+++ b/textproc/py-phonemizer-fork/files/patch-test_test__main.py
@@ -0,0 +1,19 @@
+--- test/test_main.py.orig 2024-01-01 00:00:00 UTC
++++ test/test_main.py
+@@ -56,6 +56,7 @@ def test_help():
+ assert '--quiet' in out
+
+
++@pytest.mark.skip(reason='Package metadata not available during port build')
+ def test_version():
+ runner = CliRunner()
+ result = runner.invoke(main, ['--version'])
+@@ -82,7 +83,7 @@ def test_readme_festival_syll():
+ 'for syllable boundaries')
+ def test_readme_festival_syll():
+ _test('hello world',
+- 'hh ax ;esyll l ow ;esyll ;eword w er l d ;esyll ;eword ',
++ 'hh ax l ;esyll ow ;esyll ;eword w er l d ;esyll ;eword ',
+ "-p ' ' -s ';esyll ' -w ';eword ' -b festival -l en-us")
+
+
diff --git a/textproc/py-phonemizer-fork/pkg-descr b/textproc/py-phonemizer-fork/pkg-descr
new file mode 100644
index 000000000000..9fb6c6a61ba0
--- /dev/null
+++ b/textproc/py-phonemizer-fork/pkg-descr
@@ -0,0 +1,6 @@
+phonemizer-fork is a fork of phonemizer that provides simple phonemization of
+words and texts in many languages.
+
+This is a maintained fork with additional features and bug fixes for the
+original phonemizer library, used for converting text to phonetic
+representations.