1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 cacert, 6 faster-whisper, 7 flac, 8 google-cloud-speech, 9 groq, 10 httpx, 11 openai-whisper, 12 openai, 13 pocketsphinx, 14 pyaudio, 15 pytestCheckHook, 16 pythonOlder, 17 requests, 18 respx, 19 setuptools, 20 soundfile, 21 standard-aifc, 22 typing-extensions, 23}: 24 25buildPythonPackage rec { 26 pname = "speechrecognition"; 27 version = "3.14.3"; 28 pyproject = true; 29 30 disabled = pythonOlder "3.9"; 31 32 src = fetchFromGitHub { 33 owner = "Uberi"; 34 repo = "speech_recognition"; 35 tag = version; 36 hash = "sha256-g//KKxPRe1pWVJo7GsRNIV59r0J7XJEoXvH0tGuV3Jk="; 37 }; 38 39 postPatch = '' 40 # Remove Bundled binaries 41 rm speech_recognition/flac-* 42 rm -r third-party 43 44 substituteInPlace speech_recognition/audio.py \ 45 --replace-fail 'shutil_which("flac")' '"${lib.getExe flac}"' 46 ''; 47 48 build-system = [ setuptools ]; 49 50 dependencies = [ 51 standard-aifc 52 typing-extensions 53 ]; 54 55 optional-dependencies = { 56 assemblyai = [ requests ]; 57 audio = [ pyaudio ]; 58 faster-whisper = [ faster-whisper ]; 59 google-cloud = [ google-cloud-speech ]; 60 groq = [ 61 groq 62 httpx 63 ]; 64 openai = [ 65 httpx 66 openai 67 ]; 68 pocketsphinx = [ pocketsphinx ]; 69 whisper-local = [ 70 openai-whisper 71 soundfile 72 ]; 73 }; 74 75 nativeCheckInputs = [ 76 groq 77 pytestCheckHook 78 pocketsphinx 79 respx 80 ] 81 ++ lib.flatten (lib.attrValues optional-dependencies); 82 83 pythonImportsCheck = [ "speech_recognition" ]; 84 85 disabledTests = [ 86 # Parsed string does not match expected 87 "test_sphinx_keywords" 88 ]; 89 90 meta = with lib; { 91 description = "Speech recognition module for Python, supporting several engines and APIs, online and offline"; 92 homepage = "https://github.com/Uberi/speech_recognition"; 93 changelog = "https://github.com/Uberi/speech_recognition/releases/tag/${src.tag}"; 94 license = with licenses; [ 95 gpl2Only 96 bsd3 97 ]; 98 maintainers = with maintainers; [ fab ]; 99 }; 100}