dwani 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
__init__.py ADDED
@@ -0,0 +1,44 @@
1
+ from .client import DhwaniClient
2
+
3
+ api_key = None
4
+ api_base = "http://localhost:7860"
5
+
6
+ _client = None
7
+
8
+ def _get_client():
9
+ global _client
10
+ if _client is None:
11
+ _client = DhwaniClient(api_key=api_key, api_base=api_base)
12
+ return _client
13
+
14
+ class Chat:
15
+ @staticmethod
16
+ def create(prompt):
17
+ return _get_client().chat(prompt)
18
+
19
+ class Audio:
20
+ @staticmethod
21
+ def speech(input, voice, model, response_format="mp3", output_file=None):
22
+ return _get_client().speech(input, voice, model, response_format, output_file)
23
+
24
+ class Vision:
25
+ @staticmethod
26
+ def caption(file_path, length="short"):
27
+ return _get_client().caption(file_path, length)
28
+ @staticmethod
29
+ def visual_query(file_path, query):
30
+ return _get_client().visual_query(file_path, query)
31
+ @staticmethod
32
+ def detect(file_path, object_type):
33
+ return _get_client().detect(file_path, object_type)
34
+ @staticmethod
35
+ def point(file_path, object_type):
36
+ return _get_client().point(file_path, object_type)
37
+
38
+ class ASR:
39
+ @staticmethod
40
+ def transcribe(file_path, language):
41
+ return _get_client().transcribe(file_path, language)
42
+ @staticmethod
43
+ def transcribe_batch(file_paths, language):
44
+ return _get_client().transcribe_batch(file_paths, language)
asr.py ADDED
File without changes
audio.py ADDED
File without changes
chat.py ADDED
File without changes
client.py ADDED
@@ -0,0 +1,127 @@
1
+ import os
2
+ import requests
3
+ from .exceptions import DhwaniAPIError
4
+
5
+ class DhwaniClient:
6
+ def __init__(self, api_key=None, api_base=None):
7
+ self.api_key = api_key or os.getenv("DHWANI_API_KEY")
8
+ self.api_base = api_base or os.getenv("DHWANI_API_BASE", "http://localhost:7860")
9
+ if not self.api_key:
10
+ raise ValueError("DHWANI_API_KEY not set")
11
+
12
+ def _headers(self):
13
+ return {"X-API-Key": self.api_key}
14
+
15
+ def chat(self, prompt):
16
+ resp = requests.post(
17
+ f"{self.api_base}/chat",
18
+ headers={**self._headers(), "Content-Type": "application/json"},
19
+ json={"prompt": prompt}
20
+ )
21
+ if resp.status_code != 200:
22
+ raise DhwaniAPIError(resp)
23
+ return resp.json()
24
+
25
+ def speech(self, input, voice, model, response_format="mp3", output_file=None):
26
+ data = {
27
+ "input": input,
28
+ "voice": voice,
29
+ "model": model,
30
+ "response_format": response_format
31
+ }
32
+ resp = requests.post(
33
+ f"{self.api_base}/v1/audio/speech",
34
+ headers={**self._headers(), "Content-Type": "application/json"},
35
+ json=data,
36
+ stream=True
37
+ )
38
+ if resp.status_code != 200:
39
+ raise DhwaniAPIError(resp)
40
+ if output_file:
41
+ with open(output_file, "wb") as f:
42
+ for chunk in resp.iter_content(chunk_size=8192):
43
+ f.write(chunk)
44
+ return output_file
45
+ return resp.content
46
+
47
+ def caption(self, file_path, length="short"):
48
+ with open(file_path, "rb") as f:
49
+ files = {"file": f}
50
+ data = {"length": length}
51
+ resp = requests.post(
52
+ f"{self.api_base}/caption/",
53
+ headers=self._headers(),
54
+ files=files,
55
+ data=data
56
+ )
57
+ if resp.status_code != 200:
58
+ raise DhwaniAPIError(resp)
59
+ return resp.json()
60
+
61
+ def visual_query(self, file_path, query):
62
+ with open(file_path, "rb") as f:
63
+ files = {"file": f}
64
+ data = {"query": query}
65
+ resp = requests.post(
66
+ f"{self.api_base}/visual_query/",
67
+ headers=self._headers(),
68
+ files=files,
69
+ data=data
70
+ )
71
+ if resp.status_code != 200:
72
+ raise DhwaniAPIError(resp)
73
+ return resp.json()
74
+
75
+ def detect(self, file_path, object_type):
76
+ with open(file_path, "rb") as f:
77
+ files = {"file": f}
78
+ data = {"object_type": object_type}
79
+ resp = requests.post(
80
+ f"{self.api_base}/detect/",
81
+ headers=self._headers(),
82
+ files=files,
83
+ data=data
84
+ )
85
+ if resp.status_code != 200:
86
+ raise DhwaniAPIError(resp)
87
+ return resp.json()
88
+
89
+ def point(self, file_path, object_type):
90
+ with open(file_path, "rb") as f:
91
+ files = {"file": f}
92
+ data = {"object_type": object_type}
93
+ resp = requests.post(
94
+ f"{self.api_base}/point/",
95
+ headers=self._headers(),
96
+ files=files,
97
+ data=data
98
+ )
99
+ if resp.status_code != 200:
100
+ raise DhwaniAPIError(resp)
101
+ return resp.json()
102
+
103
+ def transcribe(self, file_path, language):
104
+ with open(file_path, "rb") as f:
105
+ files = {"file": f}
106
+ resp = requests.post(
107
+ f"{self.api_base}/transcribe/?language={language}",
108
+ headers=self._headers(),
109
+ files=files
110
+ )
111
+ if resp.status_code != 200:
112
+ raise DhwaniAPIError(resp)
113
+ return resp.json()
114
+
115
+ def transcribe_batch(self, file_paths, language):
116
+ files = [("files", open(fp, "rb")) for fp in file_paths]
117
+ resp = requests.post(
118
+ f"{self.api_base}/transcribe_batch/?language={language}",
119
+ headers=self._headers(),
120
+ files=files
121
+ )
122
+ # Close all files
123
+ for _, f in files:
124
+ f.close()
125
+ if resp.status_code != 200:
126
+ raise DhwaniAPIError(resp)
127
+ return resp.json()
docs.py ADDED
File without changes
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: dwani
3
+ Version: 0.1.0
4
+ Summary: Multimodal AI server for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
5
+ Author-email: sachin <python@dwani.ai>
6
+ Project-URL: Homepage, https://github.com/dwani-ai/dwani-server
7
+ Project-URL: Source, https://github.com/dwani-ai/dwani-server
8
+ Project-URL: Issues, https://github.com/dwani-ai/dwani-server/issues
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: torch==2.6.0
12
+ Requires-Dist: torchvision
13
+ Requires-Dist: torchaudio==2.6.0
14
+ Requires-Dist: accelerate==1.6.0
15
+ Requires-Dist: bitsandbytes==0.45.5
16
+ Requires-Dist: pillow==11.1.0
17
+ Requires-Dist: uvicorn==0.34.0
18
+ Requires-Dist: fastapi==0.115.12
19
+ Requires-Dist: pydantic-settings
20
+ Requires-Dist: slowapi
21
+ Requires-Dist: python-multipart==0.0.20
22
+ Requires-Dist: packaging==24.2
23
+ Requires-Dist: tenacity
24
+ Requires-Dist: num2words
25
+ Requires-Dist: sentencepiece
26
+ Requires-Dist: huggingface-hub==0.27.1
27
+ Requires-Dist: openai
28
+ Requires-Dist: flash-attn
29
+ Requires-Dist: onnx==1.16.2
30
+ Requires-Dist: onnxruntime==1.21.0
31
+ Requires-Dist: onnxruntime-gpu==1.21.0
32
+ Requires-Dist: pydub==0.25.1
33
+ Requires-Dist: hf_xet
34
+ Requires-Dist: aiofiles==23.2.1
35
+ Requires-Dist: aiohappyeyeballs==2.6.1
36
+ Requires-Dist: aiohttp==3.11.16
37
+ Requires-Dist: aiosignal==1.3.2
38
+ Requires-Dist: annotated-types==0.7.0
39
+ Requires-Dist: antlr4-python3-runtime==4.9.3
40
+ Requires-Dist: anyio==4.9.0
41
+ Requires-Dist: async-timeout==5.0.1
42
+ Requires-Dist: attrs==25.3.0
43
+ Requires-Dist: audioread==3.0.1
44
+ Requires-Dist: boto3==1.37.29
45
+ Requires-Dist: botocore==1.37.29
46
+ Requires-Dist: cached_path==1.7.1
47
+ Requires-Dist: cachetools==5.5.2
48
+ Requires-Dist: certifi==2025.1.31
49
+ Requires-Dist: cffi==1.17.1
50
+ Requires-Dist: charset-normalizer==3.4.1
51
+ Requires-Dist: click==8.1.8
52
+ Requires-Dist: contourpy==1.3.1
53
+ Requires-Dist: cycler==0.12.1
54
+ Requires-Dist: datasets==3.5.0
55
+ Requires-Dist: decorator==5.2.1
56
+ Requires-Dist: dill==0.3.8
57
+ Requires-Dist: docker-pycreds==0.4.0
58
+ Requires-Dist: einops==0.8.1
59
+ Requires-Dist: einx==0.3.0
60
+ Requires-Dist: ema-pytorch==0.7.7
61
+ Requires-Dist: encodec==0.1.1
62
+ Requires-Dist: exceptiongroup==1.2.2
63
+ Requires-Dist: f5-tts==1.1.0
64
+ Requires-Dist: ffmpy==0.5.0
65
+ Requires-Dist: filelock==3.18.0
66
+ Requires-Dist: fonttools==4.57.0
67
+ Requires-Dist: frozendict==2.4.6
68
+ Requires-Dist: frozenlist==1.5.0
69
+ Requires-Dist: fsspec==2024.12.0
70
+ Requires-Dist: gitdb==4.0.12
71
+ Requires-Dist: GitPython==3.1.44
72
+ Requires-Dist: google-api-core==2.24.2
73
+ Requires-Dist: google-auth==2.38.0
74
+ Requires-Dist: google-cloud-core==2.4.3
75
+ Requires-Dist: google-cloud-storage==2.19.0
76
+ Requires-Dist: google-crc32c==1.7.1
77
+ Requires-Dist: google-resumable-media==2.7.2
78
+ Requires-Dist: googleapis-common-protos==1.69.2
79
+ Requires-Dist: gradio==5.14.0
80
+ Requires-Dist: gradio_client==1.7.0
81
+ Requires-Dist: groovy==0.1.2
82
+ Requires-Dist: h11==0.14.0
83
+ Requires-Dist: httpcore==1.0.7
84
+ Requires-Dist: httpx==0.28.1
85
+ Requires-Dist: hydra-core==1.3.2
86
+ Requires-Dist: idna==3.10
87
+ Requires-Dist: jieba==0.42.1
88
+ Requires-Dist: Jinja2==3.1.6
89
+ Requires-Dist: jmespath==1.0.1
90
+ Requires-Dist: joblib==1.4.2
91
+ Requires-Dist: kiwisolver==1.4.8
92
+ Requires-Dist: lazy_loader==0.4
93
+ Requires-Dist: librosa==0.11.0
94
+ Requires-Dist: llvmlite==0.44.0
95
+ Requires-Dist: loguru==0.7.3
96
+ Requires-Dist: markdown-it-py==3.0.0
97
+ Requires-Dist: MarkupSafe==2.1.5
98
+ Requires-Dist: matplotlib==3.10.1
99
+ Requires-Dist: mdurl==0.1.2
100
+ Requires-Dist: mpmath==1.3.0
101
+ Requires-Dist: msgpack==1.1.0
102
+ Requires-Dist: multidict==6.3.2
103
+ Requires-Dist: multiprocess==0.70.16
104
+ Requires-Dist: networkx==3.4.2
105
+ Requires-Dist: numba==0.61.0
106
+ Requires-Dist: numpy==1.26.4
107
+ Requires-Dist: nvidia-cublas-cu12==12.4.5.8
108
+ Requires-Dist: nvidia-cuda-cupti-cu12==12.4.127
109
+ Requires-Dist: nvidia-cuda-nvrtc-cu12==12.4.127
110
+ Requires-Dist: nvidia-cuda-runtime-cu12==12.4.127
111
+ Requires-Dist: nvidia-cudnn-cu12==9.1.0.70
112
+ Requires-Dist: nvidia-cufft-cu12==11.2.1.3
113
+ Requires-Dist: nvidia-curand-cu12==10.3.5.147
114
+ Requires-Dist: nvidia-cusolver-cu12==11.6.1.9
115
+ Requires-Dist: nvidia-cusparse-cu12==12.3.1.170
116
+ Requires-Dist: nvidia-cusparselt-cu12==0.6.2
117
+ Requires-Dist: nvidia-nccl-cu12==2.21.5
118
+ Requires-Dist: nvidia-nvjitlink-cu12==12.4.127
119
+ Requires-Dist: nvidia-nvtx-cu12==12.4.127
120
+ Requires-Dist: omegaconf==2.3.0
121
+ Requires-Dist: orjson==3.10.16
122
+ Requires-Dist: pandas==2.2.3
123
+ Requires-Dist: platformdirs==4.3.7
124
+ Requires-Dist: pooch==1.8.2
125
+ Requires-Dist: propcache==0.3.1
126
+ Requires-Dist: proto-plus==1.26.1
127
+ Requires-Dist: protobuf
128
+ Requires-Dist: psutil==7.0.0
129
+ Requires-Dist: pyarrow==19.0.1
130
+ Requires-Dist: pyasn1==0.6.1
131
+ Requires-Dist: pyasn1_modules==0.4.2
132
+ Requires-Dist: pycparser==2.22
133
+ Requires-Dist: pydantic==2.10.6
134
+ Requires-Dist: pydantic_core==2.27.2
135
+ Requires-Dist: Pygments==2.19.1
136
+ Requires-Dist: pyparsing==3.2.3
137
+ Requires-Dist: pypinyin==0.54.0
138
+ Requires-Dist: python-dateutil==2.9.0.post0
139
+ Requires-Dist: pytz==2025.2
140
+ Requires-Dist: PyYAML==6.0.2
141
+ Requires-Dist: regex==2024.11.6
142
+ Requires-Dist: requests==2.32.3
143
+ Requires-Dist: rich==13.9.4
144
+ Requires-Dist: rsa==4.9
145
+ Requires-Dist: ruff==0.11.4
146
+ Requires-Dist: s3transfer==0.11.4
147
+ Requires-Dist: safehttpx==0.1.6
148
+ Requires-Dist: safetensors==0.5.3
149
+ Requires-Dist: scikit-learn==1.6.1
150
+ Requires-Dist: scipy==1.15.2
151
+ Requires-Dist: semantic-version==2.10.0
152
+ Requires-Dist: sentry-sdk==2.25.1
153
+ Requires-Dist: setproctitle==1.3.5
154
+ Requires-Dist: shellingham==1.5.4
155
+ Requires-Dist: six==1.17.0
156
+ Requires-Dist: smmap==5.0.2
157
+ Requires-Dist: sniffio==1.3.1
158
+ Requires-Dist: soundfile==0.13.1
159
+ Requires-Dist: soxr==0.5.0.post1
160
+ Requires-Dist: starlette==0.46.1
161
+ Requires-Dist: sympy==1.13.1
162
+ Requires-Dist: threadpoolctl==3.6.0
163
+ Requires-Dist: tokenizers==0.21.1
164
+ Requires-Dist: tomli==2.2.1
165
+ Requires-Dist: tomlkit==0.13.2
166
+ Requires-Dist: torchdiffeq==0.2.5
167
+ Requires-Dist: tqdm==4.67.1
168
+ Requires-Dist: transformers==4.50.3
169
+ Requires-Dist: transformers-stream-generator==0.0.5
170
+ Requires-Dist: triton==3.2.0
171
+ Requires-Dist: typer==0.15.2
172
+ Requires-Dist: typing-inspection==0.4.0
173
+ Requires-Dist: typing_extensions==4.13.1
174
+ Requires-Dist: tzdata==2025.2
175
+ Requires-Dist: urllib3==2.3.0
176
+ Requires-Dist: vocos==0.1.0
177
+ Requires-Dist: wandb==0.19.9
178
+ Requires-Dist: websockets==14.2
179
+ Requires-Dist: x-transformers==2.2.8
180
+ Requires-Dist: xxhash==3.5.0
181
+ Requires-Dist: yarl==1.19.0
@@ -0,0 +1,12 @@
1
+ __init__.py,sha256=2tm2TJE5xuE6thkMj7um0xxCCmLE4OHtUM-M3M0H8Yo,1294
2
+ asr.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ audio.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ chat.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ client.py,sha256=BLWnHoehLZhXuDd8IPitLyuo3STmhn3TQWBziz5TXZ4,4219
6
+ docs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ exceptions.py,sha256=qEN5ukqlnN7v-kHNEnISWFMpPMt6uTft9mPsTXJ4LVA,227
8
+ vision.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ dwani-0.1.0.dist-info/METADATA,sha256=XQXwaL4Yk7_ufDAZwfg1AZDWbRt4ZpcXnnDiqEeQCRE,6100
10
+ dwani-0.1.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
11
+ dwani-0.1.0.dist-info/top_level.txt,sha256=7MBQ5IZg4CXEAt-rxOplIWS0HQcybyibcos1F-zrfOY,54
12
+ dwani-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.3.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,8 @@
1
+ __init__
2
+ asr
3
+ audio
4
+ chat
5
+ client
6
+ docs
7
+ exceptions
8
+ vision
exceptions.py ADDED
@@ -0,0 +1,5 @@
1
+ class DhwaniAPIError(Exception):
2
+ def __init__(self, response):
3
+ super().__init__(f"API Error {response.status_code}: {response.text}")
4
+ self.status_code = response.status_code
5
+ self.response = response
vision.py ADDED
File without changes