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