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