git: b0297e87d00d - main - audio/py-torchaudio: New port: PyTorch-based audio signal processing and machine learning library

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Thu, 14 Dec 2023 02:13:28 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b0297e87d00d8174ef39845e5faba0a4e1c8de03

commit b0297e87d00d8174ef39845e5faba0a4e1c8de03
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-12-14 02:12:18 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-12-14 02:13:24 +0000

    audio/py-torchaudio: New port: PyTorch-based audio signal processing and machine learning library
---
 audio/Makefile                |  1 +
 audio/py-torchaudio/Makefile  | 46 +++++++++++++++++++++++++++++++++++++++++++
 audio/py-torchaudio/distinfo  |  5 +++++
 audio/py-torchaudio/pkg-descr |  8 ++++++++
 4 files changed, 60 insertions(+)

diff --git a/audio/Makefile b/audio/Makefile
index f06f538b2b74..446c1cd6d3fc 100644
--- a/audio/Makefile
+++ b/audio/Makefile
@@ -667,6 +667,7 @@
     SUBDIR += py-speechrecognition
     SUBDIR += py-spotipy
     SUBDIR += py-tagpy
+    SUBDIR += py-torchaudio
     SUBDIR += py-wavio
     SUBDIR += py-webrtcvad
     SUBDIR += py-zita-audiotools
diff --git a/audio/py-torchaudio/Makefile b/audio/py-torchaudio/Makefile
new file mode 100644
index 000000000000..2f623ef56c63
--- /dev/null
+++ b/audio/py-torchaudio/Makefile
@@ -0,0 +1,46 @@
+PORTNAME=	torchaudio
+DISTVERSIONPREFIX=	v
+DISTVERSION=	2.1.1
+CATEGORIES=	audio python # machine-learning
+MASTER_SITES=	https://downloads.sourceforge.net/project/sox/sox/14.4.2/:sox
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+DISTFILES=	sox-14.4.2.tar.bz2:sox
+EXTRACT_ONLY=	${GH_ACCOUNT}-${GH_PROJECT}-${DISTVERSIONFULL}_GH0.tar.gz
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	PyTorch-based audio signal processing and machine learning library
+WWW=		https://pytorch.org/audio/stable/index.html
+
+LICENSE=	BSD2CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR} \
+		cmake:devel/cmake-core \
+		ninja:devel/ninja \
+		pybind11>0:devel/pybind11
+LIB_DEPENDS=	libprotobuf.so:devel/protobuf
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR}
+
+USES=		python
+USE_PYTHON=	pep517 autoplist
+
+MAKE_ENV=	USE_FFMPEG=0 # ffmpeg integration is broken or unavailable, see https://github.com/pytorch/audio/issues/3716
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	pytorch
+GH_PROJECT=	audio
+
+post-patch:
+	@${REINPLACE_CMD} \
+		-e 's| URL .*| URL file://${DISTDIR}/sox-14.4.2.tar.bz2|' \
+		${WRKSRC}/third_party/sox/CMakeLists.txt
+
+post-install:
+	@cd ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} && ${STRIP_CMD} \
+		torchaudio/lib/_torchaudio.so \
+		torchaudio/lib/_torchaudio_sox.so \
+		torchaudio/lib/libtorchaudio.so \
+		torchaudio/lib/libtorchaudio_sox.so
+
+.include <bsd.port.mk>
diff --git a/audio/py-torchaudio/distinfo b/audio/py-torchaudio/distinfo
new file mode 100644
index 000000000000..25f430b308a7
--- /dev/null
+++ b/audio/py-torchaudio/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1702517865
+SHA256 (sox-14.4.2.tar.bz2) = 81a6956d4330e75b5827316e44ae381e6f1e8928003c6aa45896da9041ea149c
+SIZE (sox-14.4.2.tar.bz2) = 935449
+SHA256 (pytorch-audio-v2.1.1_GH0.tar.gz) = fc905d8d80cec5060445f07314b5b4d276759636de87a4c21821d31d760c3974
+SIZE (pytorch-audio-v2.1.1_GH0.tar.gz) = 4414068
diff --git a/audio/py-torchaudio/pkg-descr b/audio/py-torchaudio/pkg-descr
new file mode 100644
index 000000000000..67052afd9692
--- /dev/null
+++ b/audio/py-torchaudio/pkg-descr
@@ -0,0 +1,8 @@
+The aim of torchaudio is to apply PyTorch to the audio domain. By supporting
+PyTorch, torchaudio follows the same philosophy of providing strong GPU
+acceleration, having a focus on trainable features through the autograd system,
+and having consistent style (tensor names and dimension names). Therefore, it is
+primarily a machine learning library and not a general signal processing
+library. The benefits of PyTorch can be seen in torchaudio through having all
+the computations be through PyTorch operations which makes it easy to use and
+feel like a natural extension.