maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=py3-speechrecognition
pkgver=3.14.2
pkgrel=0
pkgdesc="Library for performing speech recognition, with support for several engines and APIs, online and offline"
url="https://github.com/Uberi/speech_recognition/"
# s390x blocked by failing tests
arch="noarch !s390x"
license="BSD-3-Clause AND GPL-2.0-only"
depends="
	flac
	py3-pyaudio
	py3-requests
	py3-typing-extensions
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-httpx
	py3-numpy
	py3-pytest
	py3-respx
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/Uberi/speech_recognition/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/speech_recognition-$pkgver"

prepare() {
	default_prepare

	# Remove pre-built flac binaries, we want to use system ones instead
	rm speech_recognition/flac*
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -k 'not test_whisper and not test_sphinx_english and not test_sphinx_keywords' \
		--ignore tests/recognizers/test_google_cloud.py \
		--ignore tests/recognizers/whisper_api/test_openai.py \
		--ignore tests/recognizers/whisper_api/test_groq.py \
		--ignore tests/recognizers/whisper_local/test_faster_whisper.py
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
6e60bb1dcec6ea522b9e7aab28976ea1a825f08a8eded591598bf59eedffefd801aaa74e20879326c9a3e056282add8221f20899549c39bb6beef1e5a69c9fbb  py3-speechrecognition-3.14.2.tar.gz
"
