pkgbase=pocketsphinx
pkgname=(pocketsphinx python-pocketsphinx)
pkgver=5.1.1
pkgrel=1
pkgdesc='A small speech recognizer'
arch=('i686' 'x86_64')
url='https://cmusphinx.github.io'
license=('BSD-2-Clause' 'BSD-3-Clause' 'MIT')
depends=('glibc' libpulse)
makedepends=(git 'cmake' 'cython' 'gst-plugins-base-libs' 'ninja' 'python-build' 'python-installer' 'python-scikit-build-core' 'python-sounddevice')
source=("git-source::git+https://github.com/cmusphinx/pocketsphinx.git#tag=v${pkgver}")
sha256sums=('ad90ef9b77e5db27d05aa0c82b032581fd3254f4866938898456ad4e93c04417')

build() {
	cd git-source
	cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -DBUILD_GSTREAMER=ON
	cmake --build build
	python -m build --wheel --no-isolation
}

package_pocketsphinx() {
	cd git-source
	optdepends=('gst-plugins-base-libs: GStreamer plugin')
	DESTDIR="$pkgdir" cmake --install build
	install -vDm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgbase}/"
}
package_python-pocketsphinx() {
	cd git-source
	depends+=('python' 'python-sounddevice')
	python -m installer --destdir="${pkgdir}" dist/*.whl
	install -vDm644 LICENSE -t "$pkgdir/usr/share/licenses/python-$pkgbase/"
}
