# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=py3-speechrecognition
pkgver=3.11.0
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-numpy
	py3-pytest
	"
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_google and not test_sphinx_english and not test_sphinx_keywords'
}

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

sha512sums="
b8fcdafe819d12c44e580493d788e333e4d5adc3713707837a7051639a030a1b0381f15f291df88f4736ee9b5443e1f711b4490a73631dd1c2030f837bb15c3c  py3-speechrecognition-3.11.0.tar.gz
"
