{
lib,
buildPythonPackage,
fetchFromGitHub,
flac,
groq,
httpx,
openai-whisper,
openai,
pocketsphinx,
pyaudio,
pytestCheckHook,
pythonOlder,
requests,
respx,
setuptools,
soundfile,
typing-extensions,
}:
buildPythonPackage rec {
pname = "speechrecognition";
version = "3.12.0";
pyproject = true;
disabled = pythonOlder "3.9";
src = fetchFromGitHub {
owner = "Uberi";
repo = "speech_recognition";
rev = "refs/tags/${version}";
hash = "sha256-2yc5hztPBOysHxUQcS76ioCXmqNqjid6QUF4qPlIt24=";
};
postPatch = ''
# Remove Bundled binaries
rm speech_recognition/flac-*
rm -r third-party
substituteInPlace speech_recognition/audio.py \
--replace-fail 'shutil_which("flac")' '"${lib.getExe flac}"'
'';
build-system = [ setuptools ];
dependencies = [ typing-extensions ];
optional-dependencies = {
assemblyai = [ requests ];
audio = [ pyaudio ];
groq = [
groq
httpx
];
openai = [
openai
pocketsphinx = [ pocketsphinx ];
whisper-local = [
openai-whisper
soundfile
nativeCheckInputs = [
pytestCheckHook
pocketsphinx
respx
] ++ lib.flatten (builtins.attrValues optional-dependencies);
pythonImportsCheck = [ "speech_recognition" ];
disabledTests = [
# Parsed string does not match expected
"test_sphinx_keywords"
meta = with lib; {
description = "Speech recognition module for Python, supporting several engines and APIs, online and offline";
homepage = "https://github.com/Uberi/speech_recognition";
changelog = "https://github.com/Uberi/speech_recognition/releases/tag/${version}";
license = with licenses; [
gpl2Only
bsd3
maintainers = with maintainers; [ fab ];
}