dwani 0.1.3__py3-none-any.whl → 0.1.4__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.
- dwani/asr.py +1 -18
- dwani/audio.py +6 -6
- dwani/client.py +3 -4
- dwani/vision.py +15 -5
- {dwani-0.1.3.dist-info → dwani-0.1.4.dist-info}/METADATA +4 -4
- dwani-0.1.4.dist-info/RECORD +13 -0
- dwani-0.1.3.dist-info/RECORD +0 -13
- {dwani-0.1.3.dist-info → dwani-0.1.4.dist-info}/WHEEL +0 -0
- {dwani-0.1.3.dist-info → dwani-0.1.4.dist-info}/licenses/LICENSE +0 -0
- {dwani-0.1.3.dist-info → dwani-0.1.4.dist-info}/top_level.txt +0 -0
dwani/asr.py
CHANGED
@@ -4,7 +4,7 @@ def asr_transcribe(client, file_path, language):
|
|
4
4
|
with open(file_path, "rb") as f:
|
5
5
|
files = {"file": f}
|
6
6
|
resp = requests.post(
|
7
|
-
f"{client.api_base}/transcribe/?language={language}",
|
7
|
+
f"{client.api_base}/v1/transcribe/?language={language}",
|
8
8
|
headers=client._headers(),
|
9
9
|
files=files
|
10
10
|
)
|
@@ -18,20 +18,3 @@ class ASR:
|
|
18
18
|
from . import _get_client
|
19
19
|
return _get_client().transcribe(*args, **kwargs)
|
20
20
|
|
21
|
-
|
22
|
-
'''
|
23
|
-
from .docs import Documents
|
24
|
-
|
25
|
-
class documents:
|
26
|
-
@staticmethod
|
27
|
-
def ocr(file_path, language=None):
|
28
|
-
return _get_client().document_ocr(file_path, language)
|
29
|
-
|
30
|
-
@staticmethod
|
31
|
-
def translate(file_path, src_lang, tgt_lang):
|
32
|
-
return _get_client().document_translate(file_path, src_lang, tgt_lang)
|
33
|
-
|
34
|
-
@staticmethod
|
35
|
-
def summarize(file_path, language=None):
|
36
|
-
return _get_client().document_summarize(file_path, language)
|
37
|
-
'''
|
dwani/audio.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
from .exceptions import DhwaniAPIError
|
2
2
|
import requests
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
def audio_speech(client, input, response_format="mp3", output_file=None):
|
5
|
+
params = {
|
5
6
|
"input": input,
|
6
|
-
"voice": voice,
|
7
|
-
"model": model,
|
8
7
|
"response_format": response_format
|
9
8
|
}
|
10
9
|
resp = requests.post(
|
11
10
|
f"{client.api_base}/v1/audio/speech",
|
12
|
-
headers={**client._headers(), "
|
13
|
-
|
11
|
+
headers={**client._headers(), "accept": "application/json"},
|
12
|
+
params=params,
|
13
|
+
data='', # Empty body, as in the curl example
|
14
14
|
stream=True
|
15
15
|
)
|
16
16
|
if resp.status_code != 200:
|
dwani/client.py
CHANGED
@@ -5,7 +5,7 @@ from .exceptions import DhwaniAPIError
|
|
5
5
|
class DhwaniClient:
|
6
6
|
def __init__(self, api_key=None, api_base=None):
|
7
7
|
self.api_key = api_key or os.getenv("DWANI_API_KEY")
|
8
|
-
self.api_base = api_base or os.getenv("
|
8
|
+
self.api_base = api_base or os.getenv("DWANI_API_BASE_URL", "http://localhost:7860")
|
9
9
|
if not self.api_key:
|
10
10
|
raise ValueError("DHWANI_API_KEY not set")
|
11
11
|
|
@@ -16,14 +16,13 @@ class DhwaniClient:
|
|
16
16
|
from .chat import chat_create
|
17
17
|
return chat_create(self, prompt, src_lang, tgt_lang, **kwargs)
|
18
18
|
|
19
|
-
|
20
19
|
def speech(self, *args, **kwargs):
|
21
20
|
from .audio import audio_speech
|
22
21
|
return audio_speech(self, *args, **kwargs)
|
23
22
|
|
24
|
-
def caption(self,
|
23
|
+
def caption(self, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda"):
|
25
24
|
from .vision import vision_caption
|
26
|
-
return vision_caption(self,
|
25
|
+
return vision_caption(self, file_path, query, src_lang, tgt_lang)
|
27
26
|
|
28
27
|
def transcribe(self, *args, **kwargs):
|
29
28
|
from .asr import asr_transcribe
|
dwani/vision.py
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
from .exceptions import DhwaniAPIError
|
2
2
|
import requests
|
3
|
-
def vision_caption(client, file_path,
|
3
|
+
def vision_caption(client, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda"):
|
4
|
+
# Build the endpoint using the client's api_base
|
5
|
+
url = (
|
6
|
+
f"{client.api_base}/v1/indic_visual_query"
|
7
|
+
f"?src_lang={src_lang}&tgt_lang={tgt_lang}"
|
8
|
+
)
|
9
|
+
headers = {
|
10
|
+
**client._headers(),
|
11
|
+
"accept": "application/json"
|
12
|
+
# Note: 'Content-Type' will be set automatically by requests when using 'files'
|
13
|
+
}
|
4
14
|
with open(file_path, "rb") as f:
|
5
|
-
files = {"file": f}
|
6
|
-
data = {"
|
15
|
+
files = {"file": (file_path, f, "image/png")}
|
16
|
+
data = {"query": query}
|
7
17
|
resp = requests.post(
|
8
|
-
|
9
|
-
headers=
|
18
|
+
url,
|
19
|
+
headers=headers,
|
10
20
|
files=files,
|
11
21
|
data=data
|
12
22
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: dwani
|
3
|
-
Version: 0.1.
|
4
|
-
Summary: Multimodal
|
3
|
+
Version: 0.1.4
|
4
|
+
Summary: Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
|
5
5
|
Author-email: sachin <python@dwani.ai>
|
6
6
|
License: MIT License
|
7
7
|
|
@@ -28,7 +28,7 @@ License: MIT License
|
|
28
28
|
Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
|
29
29
|
Project-URL: Source, https://github.com/dwani-ai/dwani-python
|
30
30
|
Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
|
31
|
-
Requires-Python: >=3.
|
31
|
+
Requires-Python: >=3.8
|
32
32
|
Description-Content-Type: text/markdown
|
33
33
|
License-File: LICENSE
|
34
34
|
Requires-Dist: requests>=2.25.0
|
@@ -49,7 +49,7 @@ import os
|
|
49
49
|
|
50
50
|
dwani.api_key = os.getenv("DWANI_API_KEY")
|
51
51
|
|
52
|
-
dwani.api_base = os.getenv("
|
52
|
+
dwani.api_base = os.getenv("DWANI_API_BASE_URL")
|
53
53
|
|
54
54
|
resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
|
55
55
|
print(resp)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
dwani/__init__.py,sha256=P2pyHkZ7JHn6lHSEbCdV4hjYAwCOXHN3RbsNIU0F5PE,1084
|
2
|
+
dwani/asr.py,sha256=Y5Mbv1KsvhfXNZacMZycUHPn79NRQC-XPH0j9SYPUSY,590
|
3
|
+
dwani/audio.py,sha256=Q9vw4uBxGy1vQzmiZjZGrY8hkAEQNkGhjz5OcnpFEQQ,888
|
4
|
+
dwani/chat.py,sha256=WFuEShNd4nd6KUbIZTkm3eyPGoP33GepOLJax86nNn8,720
|
5
|
+
dwani/client.py,sha256=DmGF93Doibam-rPuV64XlyIwgiWrDJigXZNBCkPz-ho,1601
|
6
|
+
dwani/docs.py,sha256=2B87KqshPl7-2gDJAJxdvcgmPWuC2IQ1FcsDIyeVJPg,2202
|
7
|
+
dwani/exceptions.py,sha256=qEN5ukqlnN7v-kHNEnISWFMpPMt6uTft9mPsTXJ4LVA,227
|
8
|
+
dwani/vision.py,sha256=JtMSS0hI-8gxtLugVP10__enZsPPy8jheMyWXvrGrdw,1015
|
9
|
+
dwani-0.1.4.dist-info/licenses/LICENSE,sha256=IAD8tbwWZbPWHXgYjabHoMv0aaUzZUYzYiEbfhTCisY,1070
|
10
|
+
dwani-0.1.4.dist-info/METADATA,sha256=MZunthMWfUpXPchujVFu20UZDSURcnSd7FRWLt7KCos,2158
|
11
|
+
dwani-0.1.4.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
12
|
+
dwani-0.1.4.dist-info/top_level.txt,sha256=AM5EhkyuO_EXQFR9JIxEV6tAYMCCyc-a1dLifpCGBUk,6
|
13
|
+
dwani-0.1.4.dist-info/RECORD,,
|
dwani-0.1.3.dist-info/RECORD
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
dwani/__init__.py,sha256=P2pyHkZ7JHn6lHSEbCdV4hjYAwCOXHN3RbsNIU0F5PE,1084
|
2
|
-
dwani/asr.py,sha256=Xe62t8dNQy9gRkn4LyjaagOXjKZ90aexYEL2D-oVP2U,1042
|
3
|
-
dwani/audio.py,sha256=lyFjYAv4EsDIHPbopv9Lf5LJIzuJEuoBO9H37TVGaUo,894
|
4
|
-
dwani/chat.py,sha256=WFuEShNd4nd6KUbIZTkm3eyPGoP33GepOLJax86nNn8,720
|
5
|
-
dwani/client.py,sha256=qtXDAv9t-Eu5HGvH4ubrcmIIH8VgrTHn0c_Ozm4-cmQ,1513
|
6
|
-
dwani/docs.py,sha256=2B87KqshPl7-2gDJAJxdvcgmPWuC2IQ1FcsDIyeVJPg,2202
|
7
|
-
dwani/exceptions.py,sha256=qEN5ukqlnN7v-kHNEnISWFMpPMt6uTft9mPsTXJ4LVA,227
|
8
|
-
dwani/vision.py,sha256=xi9gVsL8MA8VQYXIV99uqKuxYfs1kWu4tvqzbe95F1Y,623
|
9
|
-
dwani-0.1.3.dist-info/licenses/LICENSE,sha256=IAD8tbwWZbPWHXgYjabHoMv0aaUzZUYzYiEbfhTCisY,1070
|
10
|
-
dwani-0.1.3.dist-info/METADATA,sha256=KALRQIuxWFjbHHsF8QAdHHs76DVcfSAUPoWsGBcOsFs,2161
|
11
|
-
dwani-0.1.3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
12
|
-
dwani-0.1.3.dist-info/top_level.txt,sha256=AM5EhkyuO_EXQFR9JIxEV6tAYMCCyc-a1dLifpCGBUk,6
|
13
|
-
dwani-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|