1
0
mirror of https://git.freebsd.org/ports.git synced 2026-06-02 11:08:52 +00:00

textproc/py-phonemizer-fork: New port: Fork of phonemizer for text to phones conversion

This commit is contained in:
Yuri Victorovich
2026-03-16 10:12:14 -07:00
parent e104e35670
commit dcbb782b0c
8 changed files with 145 additions and 0 deletions
+1
View File
@@ -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
+62
View File
@@ -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>
+3
View File
@@ -0,0 +1,3 @@
TIMESTAMP = 1773625361
SHA256 (phonemizer_fork-3.3.2.tar.gz) = 10e16e827d0443b087062e21b55e805c00989cf1343b2e81e734cae5f6c0cf69
SIZE (phonemizer_fork-3.3.2.tar.gz) = 300989
@@ -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")
@@ -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'] = (
@@ -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')
@@ -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")
+6
View File
@@ -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.