git: c60253778d00 - main - misc/py-kokoro: Add test
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Mar 2026 14:25:26 UTC
The branch main has been updated by yuri:
URL: https://cgit.FreeBSD.org/ports/commit/?id=c60253778d002a267db6ef4188ee9320a3a868bb
commit c60253778d002a267db6ef4188ee9320a3a868bb
Author: Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-03-17 14:25:11 +0000
Commit: Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-03-17 14:25:11 +0000
misc/py-kokoro: Add test
---
misc/py-kokoro/Makefile | 10 +++++++++-
misc/py-kokoro/files/example.py | 16 ++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/misc/py-kokoro/Makefile b/misc/py-kokoro/Makefile
index 2b513062713f..cd8c6aa93df4 100644
--- a/misc/py-kokoro/Makefile
+++ b/misc/py-kokoro/Makefile
@@ -1,6 +1,6 @@
PORTNAME= kokoro
DISTVERSION= 0.9.4
-CATEGORIES= misc python
+CATEGORIES= misc python # machine-learning
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
@@ -20,10 +20,18 @@ RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}huggingface-hub>0:misc/py-huggingface-hub@${
${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}spacy>0:textproc/py-spacy@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}transformers>=0:misc/py-transformers@${PY_FLAVOR}
+TEST_DEPENDS= mpv:multimedia/mpv
USES= python
USE_PYTHON= autoplist concurrent pep517
NO_ARCH= yes
+TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
+do-test:
+ @cd ${WRKSRC} && \
+ ${SETENV} ${TEST_ENV} ${PYTHON_CMD} ${FILESDIR}/example.py && \
+ mpv 0.wav
+
.include <bsd.port.mk>
diff --git a/misc/py-kokoro/files/example.py b/misc/py-kokoro/files/example.py
new file mode 100644
index 000000000000..03dfa69606d9
--- /dev/null
+++ b/misc/py-kokoro/files/example.py
@@ -0,0 +1,16 @@
+from kokoro import KPipeline
+from IPython.display import display, Audio
+import soundfile as sf
+import torch
+
+pipeline = KPipeline(lang_code='a')
+
+text = '''
+FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable home-class hardware, and has since continuously been the most commonly used BSD-derived operating system.
+'''
+
+generator = pipeline(text, voice='af_heart')
+for i, (gs, ps, audio) in enumerate(generator):
+ print(i, gs, ps)
+ display(Audio(data=audio, rate=24000, autoplay=i==0))
+ sf.write(f'{i}.wav', audio, 24000)