dwani 0.1.4__tar.gz → 0.1.6__tar.gz

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-0.1.6/PKG-INFO ADDED
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: dwani
3
+ Version: 0.1.6
4
+ Summary: Multimodal API for Indian languages (Chat, Vision, TTS, ASR, Translate, Docs)
5
+ Author-email: sachin <python@dwani.ai>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Sachin Shetty
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
29
+ Project-URL: Source, https://github.com/dwani-ai/dwani-python
30
+ Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
31
+ Requires-Python: >=3.8
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Requires-Dist: requests>=2.25.0
35
+ Dynamic: license-file
36
+
37
+ # dwani.ai - python library
38
+
39
+
40
+ ### Install the library
41
+ ```bash
42
+ pip install dwani
43
+ ```
44
+
45
+ ### Setup the credentials
46
+ ```python
47
+ import dwani
48
+ import os
49
+
50
+ dwani.api_key = os.getenv("DWANI_API_KEY")
51
+
52
+ dwani.api_base = os.getenv("DWANI_API_BASE_URL")
53
+ ```
54
+
55
+ ### Examples
56
+
57
+ #### Text Query
58
+ ```python
59
+ resp = dwani.Chat.create(prompt="Hello!", src_lang="eng_Latn", tgt_lang="kan_Knda")
60
+ print(resp)
61
+ ```
62
+ ```json
63
+ {'response': 'ನಮಸ್ತೆ! ಭಾರತ ಮತ್ತು ಕರ್ನಾಟಕವನ್ನು ಗಮನದಲ್ಲಿಟ್ಟುಕೊಂಡು ಇಂದು ನಿಮ್ಮ ಪ್ರಶ್ನೆಗಳಿಗೆ ನಾನು ನಿಮಗೆ ಹೇಗೆ ಸಹಾಯ ಮಾಡಲಿ?'}
64
+ ```
65
+
66
+
67
+ #### Vision Query
68
+ ```python
69
+ result = dwani.Vision.caption(
70
+ file_path="image.png",
71
+ query="Describe this logo",
72
+ src_lang="eng_Latn",
73
+ tgt_lang="kan_Knda"
74
+ )
75
+ print(result)
76
+ ```
77
+ ```json
78
+ {'answer': 'ಒಂದು ವಾಕ್ಯದಲ್ಲಿ ಚಿತ್ರದ ಸಾರಾಂಶವನ್ನು ಇಲ್ಲಿ ನೀಡಲಾಗಿದೆಃ ಪ್ರಕಟಣೆಯ ಅವಲೋಕನವು ಪ್ರಸ್ತುತ ಅರವತ್ತನಾಲ್ಕು ದೇಶಗಳು/ಪ್ರದೇಶಗಳನ್ನು ಸೇರಿಸಲಾಗಿದೆ ಮತ್ತು ಇನ್ನೂ ಹದಿನಾರು ಪ್ರದೇಶಗಳನ್ನು ಸೇರಿಸಬೇಕಾಗಿದೆ. ಒದಗಿಸಲಾದ ಚಿತ್ರದಲ್ಲಿ ಲಾಂಛನವು ಕಾಣಿಸುವುದಿಲ್ಲ.'}
79
+ ```
80
+
81
+ #### Speech to Text - Automatic Speech Recognition (ASR)
82
+ ```python
83
+ result = dwani.ASR.transcribe(file_path="kannada_sample.wav", language="kannada")
84
+ print(result)
85
+ ```
86
+ ```json
87
+ {'text': 'ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು'}
88
+ ```
89
+
90
+ ### Translate
91
+ ```python
92
+ resp = dwani.Translate.run_translate(sentences=["hi"], src_lang="eng_Latn", tgt_lang="kan_Knda")
93
+ print(resp)
94
+ ```
95
+ ```json
96
+ {'translations': ['ಹಾಯ್']}
97
+ ```
98
+ #### Text to Speech - Speech Synthesis
99
+
100
+ ```python
101
+ response = dwani.Audio.speech(input="ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು", response_format="mp3")
102
+ with open("output.mp3", "wb") as f:
103
+ f.write(response)
104
+ ```
105
+
106
+ #### Document - Extract Text
107
+ ```python
108
+ result = dwani.Documents.run_extract(file_path = "dwani-workshop.pdf", page_number=1, src_lang="eng_Latn",tgt_lang="kan_Knda" )
109
+ print(result)
110
+ ```
111
+ ```json
112
+ {'pages': [{'processed_page': 1, 'page_content': ' a plain text representation of the document', 'translated_content': 'ಡಾಕ್ಯುಮೆಂಟ್ನ ಸರಳ ಪಠ್ಯ ಪ್ರಾತಿನಿಧ್ಯವನ್ನು ಇಲ್ಲಿ ನೀಡಲಾಗಿದೆ, ಅದನ್ನು ಸ್ವಾಭಾವಿಕವಾಗಿ ಓದುವಂತೆಃ'}]}
113
+ ```
114
+
115
+ - Website -> [dwani.ai](https://dwani.ai)
116
+
117
+
118
+ <!--
119
+ ## local development
120
+ pip install -e .
121
+
122
+
123
+ pip install twine build
124
+ rm -rf dist/
125
+ python -m build
126
+
127
+ python -m twine upload dist/*
128
+
129
+ -->
dwani-0.1.6/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # dwani.ai - python library
2
+
3
+
4
+ ### Install the library
5
+ ```bash
6
+ pip install dwani
7
+ ```
8
+
9
+ ### Setup the credentials
10
+ ```python
11
+ import dwani
12
+ import os
13
+
14
+ dwani.api_key = os.getenv("DWANI_API_KEY")
15
+
16
+ dwani.api_base = os.getenv("DWANI_API_BASE_URL")
17
+ ```
18
+
19
+ ### Examples
20
+
21
+ #### Text Query
22
+ ```python
23
+ resp = dwani.Chat.create(prompt="Hello!", src_lang="eng_Latn", tgt_lang="kan_Knda")
24
+ print(resp)
25
+ ```
26
+ ```json
27
+ {'response': 'ನಮಸ್ತೆ! ಭಾರತ ಮತ್ತು ಕರ್ನಾಟಕವನ್ನು ಗಮನದಲ್ಲಿಟ್ಟುಕೊಂಡು ಇಂದು ನಿಮ್ಮ ಪ್ರಶ್ನೆಗಳಿಗೆ ನಾನು ನಿಮಗೆ ಹೇಗೆ ಸಹಾಯ ಮಾಡಲಿ?'}
28
+ ```
29
+
30
+
31
+ #### Vision Query
32
+ ```python
33
+ result = dwani.Vision.caption(
34
+ file_path="image.png",
35
+ query="Describe this logo",
36
+ src_lang="eng_Latn",
37
+ tgt_lang="kan_Knda"
38
+ )
39
+ print(result)
40
+ ```
41
+ ```json
42
+ {'answer': 'ಒಂದು ವಾಕ್ಯದಲ್ಲಿ ಚಿತ್ರದ ಸಾರಾಂಶವನ್ನು ಇಲ್ಲಿ ನೀಡಲಾಗಿದೆಃ ಪ್ರಕಟಣೆಯ ಅವಲೋಕನವು ಪ್ರಸ್ತುತ ಅರವತ್ತನಾಲ್ಕು ದೇಶಗಳು/ಪ್ರದೇಶಗಳನ್ನು ಸೇರಿಸಲಾಗಿದೆ ಮತ್ತು ಇನ್ನೂ ಹದಿನಾರು ಪ್ರದೇಶಗಳನ್ನು ಸೇರಿಸಬೇಕಾಗಿದೆ. ಒದಗಿಸಲಾದ ಚಿತ್ರದಲ್ಲಿ ಲಾಂಛನವು ಕಾಣಿಸುವುದಿಲ್ಲ.'}
43
+ ```
44
+
45
+ #### Speech to Text - Automatic Speech Recognition (ASR)
46
+ ```python
47
+ result = dwani.ASR.transcribe(file_path="kannada_sample.wav", language="kannada")
48
+ print(result)
49
+ ```
50
+ ```json
51
+ {'text': 'ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು'}
52
+ ```
53
+
54
+ ### Translate
55
+ ```python
56
+ resp = dwani.Translate.run_translate(sentences=["hi"], src_lang="eng_Latn", tgt_lang="kan_Knda")
57
+ print(resp)
58
+ ```
59
+ ```json
60
+ {'translations': ['ಹಾಯ್']}
61
+ ```
62
+ #### Text to Speech - Speech Synthesis
63
+
64
+ ```python
65
+ response = dwani.Audio.speech(input="ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು", response_format="mp3")
66
+ with open("output.mp3", "wb") as f:
67
+ f.write(response)
68
+ ```
69
+
70
+ #### Document - Extract Text
71
+ ```python
72
+ result = dwani.Documents.run_extract(file_path = "dwani-workshop.pdf", page_number=1, src_lang="eng_Latn",tgt_lang="kan_Knda" )
73
+ print(result)
74
+ ```
75
+ ```json
76
+ {'pages': [{'processed_page': 1, 'page_content': ' a plain text representation of the document', 'translated_content': 'ಡಾಕ್ಯುಮೆಂಟ್ನ ಸರಳ ಪಠ್ಯ ಪ್ರಾತಿನಿಧ್ಯವನ್ನು ಇಲ್ಲಿ ನೀಡಲಾಗಿದೆ, ಅದನ್ನು ಸ್ವಾಭಾವಿಕವಾಗಿ ಓದುವಂತೆಃ'}]}
77
+ ```
78
+
79
+ - Website -> [dwani.ai](https://dwani.ai)
80
+
81
+
82
+ <!--
83
+ ## local development
84
+ pip install -e .
85
+
86
+
87
+ pip install twine build
88
+ rm -rf dist/
89
+ python -m build
90
+
91
+ python -m twine upload dist/*
92
+
93
+ -->
@@ -3,9 +3,11 @@ from .chat import Chat
3
3
  from .audio import Audio
4
4
  from .vision import Vision
5
5
  from .asr import ASR
6
+ from .translate import Translate
6
7
  from .exceptions import DhwaniAPIError
8
+ from .docs import Documents
7
9
 
8
- __all__ = ["DhwaniClient", "Chat", "Audio", "Vision", "ASR", "DhwaniAPIError"]
10
+ __all__ = ["DhwaniClient", "Chat", "Audio", "Vision", "ASR", "DhwaniAPIError", "Translate", "Documents"]
9
11
 
10
12
  # Optionally, instantiate a default client for convenience
11
13
  api_key = None
@@ -37,3 +39,27 @@ class asr:
37
39
  @staticmethod
38
40
  def transcribe(*args, **kwargs):
39
41
  return _get_client().transcribe(*args, **kwargs)
42
+
43
+
44
+ class translate:
45
+ @staticmethod
46
+ def run_translate(*args, **kwargs):
47
+ return _get_client().translate(*args, **kwargs)
48
+
49
+
50
+ class document:
51
+ @staticmethod
52
+ def run_ocr(*args, **kwargs):
53
+ return _get_client().ocr(*args, **kwargs)
54
+ @staticmethod
55
+ def run_summarize(*args, **kwargs):
56
+ return _get_client().summarize(*args, **kwargs)
57
+ @staticmethod
58
+ def run_extract(*args, **kwargs):
59
+ return _get_client().extract(*args, **kwargs)
60
+ @staticmethod
61
+ def run_doc_query(*args, **kwargs):
62
+ return _get_client().doc_query(*args, **kwargs)
63
+ @staticmethod
64
+ def run_doc_query_kannada(*args, **kwargs):
65
+ return _get_client().doc_query_kannada(*args, **kwargs)
@@ -0,0 +1,54 @@
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("DWANI_API_KEY")
8
+ self.api_base = api_base or os.getenv("DWANI_API_BASE_URL", "http://localhost:8000")
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 translate(self, sentences, src_lang, tgt_lang, **kwargs):
16
+ from .translate import run_translate
17
+ return run_translate(self, sentences=sentences, src_lang=src_lang, tgt_lang=tgt_lang, **kwargs)
18
+
19
+ def chat(self, prompt, src_lang, tgt_lang, **kwargs):
20
+ from .chat import chat_create
21
+ return chat_create(self, prompt=prompt, src_lang=src_lang, tgt_lang=tgt_lang, **kwargs)
22
+
23
+ def speech(self, input, response_format="mp3", **kwargs):
24
+ from .audio import audio_speech
25
+ return audio_speech(self, input=input, response_format=response_format, **kwargs)
26
+
27
+ def caption(self, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda", **kwargs):
28
+ from .vision import vision_caption
29
+ return vision_caption(self, file_path=file_path, query=query, src_lang=src_lang, tgt_lang=tgt_lang, **kwargs)
30
+
31
+ def transcribe(self, file_path, language=None, **kwargs):
32
+ from .asr import asr_transcribe
33
+ return asr_transcribe(self, file_path=file_path, language=language, **kwargs)
34
+
35
+ def document_ocr(self, file_path, language=None, **kwargs):
36
+ from .docs import document_ocr
37
+ return document_ocr(self, file_path=file_path, language=language, **kwargs)
38
+
39
+ def document_summarize(self, file_path, page_number=1, src_lang="eng_Latn", tgt_lang="kan_Knda", **kwargs):
40
+ from .docs import document_summarize
41
+ return document_summarize(self, file_path, page_number, src_lang, tgt_lang, **kwargs)
42
+
43
+ def extract(self, file_path, page_number=1, src_lang="eng_Latn", tgt_lang="kan_Knda", **kwargs):
44
+ from .docs import extract
45
+ return extract(self, file_path=file_path, page_number=page_number, src_lang=src_lang,tgt_lang=tgt_lang, **kwargs)
46
+
47
+
48
+ def doc_query( self, file_path, page_number=1, prompt="list the key points", src_lang="eng_Latn", tgt_lang="kan_Knda" , **kwargs ):
49
+ from .docs import doc_query
50
+ return doc_query( self, file_path, page_number=page_number, prompt=prompt, src_lang=src_lang, tgt_lang=tgt_lang , **kwargs )
51
+
52
+ def doc_query_kannada(self, file_path, page_number=1, prompt="list key points", src_lang="eng_Latn", language=None, **kwargs):
53
+ from .docs import doc_query_kannada
54
+ return doc_query_kannada(self, file_path=file_path, page_number=page_number, prompt=prompt, src_lang=src_lang, language=language, **kwargs)
@@ -0,0 +1,149 @@
1
+ import requests
2
+ from .exceptions import DhwaniAPIError
3
+
4
+ def document_ocr(client, file_path, language=None):
5
+ """OCR a document (image/PDF) and return extracted text."""
6
+ with open(file_path, "rb") as f:
7
+ files = {"file": f}
8
+ data = {}
9
+ if language:
10
+ data["language"] = language
11
+ resp = requests.post(
12
+ f"{client.api_base}/v1/document/ocr",
13
+ headers=client._headers(),
14
+ files=files,
15
+ data=data
16
+ )
17
+ if resp.status_code != 200:
18
+ raise DhwaniAPIError(resp)
19
+ return resp.json()
20
+
21
+ def document_summarize(client, file_path, page_number=1, src_lang="eng_Latn", tgt_lang="kan_Knda"):
22
+ """Summarize a PDF document with language and page number options."""
23
+ url = f"{client.api_base}/v1/indic-summarize-pdf"
24
+ headers = client._headers()
25
+ with open(file_path, "rb") as f:
26
+ files = {"file": (file_path, f, "application/pdf")}
27
+ data = {
28
+ "page_number": str(page_number),
29
+ "src_lang": src_lang,
30
+ "tgt_lang": tgt_lang
31
+ }
32
+ resp = requests.post(
33
+ url,
34
+ headers=headers,
35
+ files=files,
36
+ data=data
37
+ )
38
+ if resp.status_code != 200:
39
+ raise DhwaniAPIError(resp)
40
+ return resp.json()
41
+
42
+
43
+ def extract(client, file_path, page_number, src_lang, tgt_lang):
44
+ """
45
+ Extract and translate text from a document (image/PDF) using query parameters.
46
+ """
47
+ # Build the URL with query parameters
48
+ url = (
49
+ f"{client.api_base}/v1/indic-extract-text/"
50
+ f"?page_number={page_number}&src_lang={src_lang}&tgt_lang={tgt_lang}"
51
+ )
52
+ headers = client._headers()
53
+ # 'requests' handles multipart/form-data automatically
54
+ with open(file_path, "rb") as f:
55
+ files = {"file": (file_path, f, "application/pdf")}
56
+ resp = requests.post(
57
+ url,
58
+ headers=headers,
59
+ files=files
60
+ )
61
+ if resp.status_code != 200:
62
+ raise DhwaniAPIError(resp)
63
+ return resp.json()
64
+
65
+ def doc_query(
66
+ client,
67
+ file_path,
68
+ page_number=1,
69
+ prompt="list the key points",
70
+ src_lang="eng_Latn",
71
+ tgt_lang="kan_Knda"
72
+ ):
73
+ """Query a document with a custom prompt and language options."""
74
+ url = f"{client.api_base}/v1/indic-custom-prompt-pdf"
75
+ headers = client._headers()
76
+ with open(file_path, "rb") as f:
77
+ files = {"file": (file_path, f, "application/pdf")}
78
+ data = {
79
+ "page_number": str(page_number),
80
+ "prompt": prompt,
81
+ "source_language": src_lang,
82
+ "target_language": tgt_lang
83
+ }
84
+ resp = requests.post(
85
+ url,
86
+ headers=headers,
87
+ files=files,
88
+ data=data
89
+ )
90
+ if resp.status_code != 200:
91
+ raise DhwaniAPIError(resp)
92
+ return resp.json()
93
+
94
+
95
+ def doc_query_kannada(
96
+ client,
97
+ file_path,
98
+ page_number=1,
99
+ prompt="list key points",
100
+ src_lang="eng_Latn",
101
+ language=None
102
+ ):
103
+ """Summarize a document (image/PDF/text) with custom prompt and language."""
104
+ url = f"{client.api_base}/v1/indic-custom-prompt-kannada-pdf"
105
+ headers = client._headers()
106
+ # 'requests' will handle multipart/form-data automatically
107
+ with open(file_path, "rb") as f:
108
+ files = {"file": (file_path, f, "application/pdf")}
109
+ data = {
110
+ "page_number": str(page_number),
111
+ "prompt": prompt,
112
+ "src_lang": src_lang,
113
+ }
114
+ if language:
115
+ data["language"] = language
116
+ resp = requests.post(
117
+ url,
118
+ headers=headers,
119
+ files=files,
120
+ data=data
121
+ )
122
+ if resp.status_code != 200:
123
+ raise DhwaniAPIError(resp)
124
+ return resp.json()
125
+
126
+
127
+
128
+ class Documents:
129
+ @staticmethod
130
+ def ocr(file_path, language=None):
131
+ from . import _get_client
132
+ return _get_client().document_ocr(file_path, language)
133
+
134
+ @staticmethod
135
+ def summarize(*args, **kwargs):
136
+ from . import _get_client
137
+ return _get_client().document_summarize(*args, **kwargs)
138
+ @staticmethod
139
+ def run_extract(*args, **kwargs):
140
+ from . import _get_client
141
+ return _get_client().extract(*args, **kwargs)
142
+ @staticmethod
143
+ def run_doc_query(*args, **kwargs):
144
+ from . import _get_client
145
+ return _get_client().doc_query(*args, **kwargs)
146
+ @staticmethod
147
+ def run_doc_query_kannada(*args, **kwargs):
148
+ from . import _get_client
149
+ return _get_client().doc_query_kannada(*args, **kwargs)
@@ -0,0 +1,26 @@
1
+ from .exceptions import DhwaniAPIError
2
+ import requests
3
+
4
+ def run_translate(client, sentences, src_lang, tgt_lang, **kwargs):
5
+ url = f"{client.api_base}/v1/translate"
6
+ payload = {
7
+ "sentences": sentences,
8
+ "src_lang": src_lang,
9
+ "tgt_lang": tgt_lang
10
+ }
11
+ payload.update(kwargs)
12
+ resp = requests.post(
13
+ url,
14
+ headers={**client._headers(), "Content-Type": "application/json", "accept": "application/json"},
15
+ json=payload
16
+ )
17
+ if resp.status_code != 200:
18
+ raise DhwaniAPIError(resp)
19
+ return resp.json()
20
+
21
+ class Translate:
22
+ @staticmethod
23
+ def run_translate(sentences, src_lang, tgt_lang, **kwargs):
24
+ from . import _get_client
25
+ return _get_client().translate(sentences, src_lang, tgt_lang, **kwargs)
26
+
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: dwani
3
+ Version: 0.1.6
4
+ Summary: Multimodal API for Indian languages (Chat, Vision, TTS, ASR, Translate, Docs)
5
+ Author-email: sachin <python@dwani.ai>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Sachin Shetty
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
29
+ Project-URL: Source, https://github.com/dwani-ai/dwani-python
30
+ Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
31
+ Requires-Python: >=3.8
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Requires-Dist: requests>=2.25.0
35
+ Dynamic: license-file
36
+
37
+ # dwani.ai - python library
38
+
39
+
40
+ ### Install the library
41
+ ```bash
42
+ pip install dwani
43
+ ```
44
+
45
+ ### Setup the credentials
46
+ ```python
47
+ import dwani
48
+ import os
49
+
50
+ dwani.api_key = os.getenv("DWANI_API_KEY")
51
+
52
+ dwani.api_base = os.getenv("DWANI_API_BASE_URL")
53
+ ```
54
+
55
+ ### Examples
56
+
57
+ #### Text Query
58
+ ```python
59
+ resp = dwani.Chat.create(prompt="Hello!", src_lang="eng_Latn", tgt_lang="kan_Knda")
60
+ print(resp)
61
+ ```
62
+ ```json
63
+ {'response': 'ನಮಸ್ತೆ! ಭಾರತ ಮತ್ತು ಕರ್ನಾಟಕವನ್ನು ಗಮನದಲ್ಲಿಟ್ಟುಕೊಂಡು ಇಂದು ನಿಮ್ಮ ಪ್ರಶ್ನೆಗಳಿಗೆ ನಾನು ನಿಮಗೆ ಹೇಗೆ ಸಹಾಯ ಮಾಡಲಿ?'}
64
+ ```
65
+
66
+
67
+ #### Vision Query
68
+ ```python
69
+ result = dwani.Vision.caption(
70
+ file_path="image.png",
71
+ query="Describe this logo",
72
+ src_lang="eng_Latn",
73
+ tgt_lang="kan_Knda"
74
+ )
75
+ print(result)
76
+ ```
77
+ ```json
78
+ {'answer': 'ಒಂದು ವಾಕ್ಯದಲ್ಲಿ ಚಿತ್ರದ ಸಾರಾಂಶವನ್ನು ಇಲ್ಲಿ ನೀಡಲಾಗಿದೆಃ ಪ್ರಕಟಣೆಯ ಅವಲೋಕನವು ಪ್ರಸ್ತುತ ಅರವತ್ತನಾಲ್ಕು ದೇಶಗಳು/ಪ್ರದೇಶಗಳನ್ನು ಸೇರಿಸಲಾಗಿದೆ ಮತ್ತು ಇನ್ನೂ ಹದಿನಾರು ಪ್ರದೇಶಗಳನ್ನು ಸೇರಿಸಬೇಕಾಗಿದೆ. ಒದಗಿಸಲಾದ ಚಿತ್ರದಲ್ಲಿ ಲಾಂಛನವು ಕಾಣಿಸುವುದಿಲ್ಲ.'}
79
+ ```
80
+
81
+ #### Speech to Text - Automatic Speech Recognition (ASR)
82
+ ```python
83
+ result = dwani.ASR.transcribe(file_path="kannada_sample.wav", language="kannada")
84
+ print(result)
85
+ ```
86
+ ```json
87
+ {'text': 'ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು'}
88
+ ```
89
+
90
+ ### Translate
91
+ ```python
92
+ resp = dwani.Translate.run_translate(sentences=["hi"], src_lang="eng_Latn", tgt_lang="kan_Knda")
93
+ print(resp)
94
+ ```
95
+ ```json
96
+ {'translations': ['ಹಾಯ್']}
97
+ ```
98
+ #### Text to Speech - Speech Synthesis
99
+
100
+ ```python
101
+ response = dwani.Audio.speech(input="ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು", response_format="mp3")
102
+ with open("output.mp3", "wb") as f:
103
+ f.write(response)
104
+ ```
105
+
106
+ #### Document - Extract Text
107
+ ```python
108
+ result = dwani.Documents.run_extract(file_path = "dwani-workshop.pdf", page_number=1, src_lang="eng_Latn",tgt_lang="kan_Knda" )
109
+ print(result)
110
+ ```
111
+ ```json
112
+ {'pages': [{'processed_page': 1, 'page_content': ' a plain text representation of the document', 'translated_content': 'ಡಾಕ್ಯುಮೆಂಟ್ನ ಸರಳ ಪಠ್ಯ ಪ್ರಾತಿನಿಧ್ಯವನ್ನು ಇಲ್ಲಿ ನೀಡಲಾಗಿದೆ, ಅದನ್ನು ಸ್ವಾಭಾವಿಕವಾಗಿ ಓದುವಂತೆಃ'}]}
113
+ ```
114
+
115
+ - Website -> [dwani.ai](https://dwani.ai)
116
+
117
+
118
+ <!--
119
+ ## local development
120
+ pip install -e .
121
+
122
+
123
+ pip install twine build
124
+ rm -rf dist/
125
+ python -m build
126
+
127
+ python -m twine upload dist/*
128
+
129
+ -->
@@ -8,6 +8,7 @@ dwani/chat.py
8
8
  dwani/client.py
9
9
  dwani/docs.py
10
10
  dwani/exceptions.py
11
+ dwani/translate.py
11
12
  dwani/vision.py
12
13
  dwani.egg-info/PKG-INFO
13
14
  dwani.egg-info/SOURCES.txt
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dwani"
7
- version = "0.1.4"
8
- description = "Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)"
7
+ version = "0.1.6"
8
+ description = "Multimodal API for Indian languages (Chat, Vision, TTS, ASR, Translate, Docs)"
9
9
  authors = [
10
10
  { name="sachin", email="python@dwani.ai" }
11
11
  ]
dwani-0.1.4/PKG-INFO DELETED
@@ -1,70 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: dwani
3
- Version: 0.1.4
4
- Summary: Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
5
- Author-email: sachin <python@dwani.ai>
6
- License: MIT License
7
-
8
- Copyright (c) 2025 Sachin Shetty
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
29
- Project-URL: Source, https://github.com/dwani-ai/dwani-python
30
- Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
31
- Requires-Python: >=3.8
32
- Description-Content-Type: text/markdown
33
- License-File: LICENSE
34
- Requires-Dist: requests>=2.25.0
35
- Dynamic: license-file
36
-
37
- # dwani.ai - python library
38
-
39
-
40
- ```bash
41
- pip install dwani
42
- ```
43
-
44
-
45
-
46
- ```python
47
- import dwani
48
- import os
49
-
50
- dwani.api_key = os.getenv("DWANI_API_KEY")
51
-
52
- dwani.api_base = os.getenv("DWANI_API_BASE_URL")
53
-
54
- resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
55
- print(resp)
56
- ```
57
-
58
-
59
- <!--
60
- ## local development
61
- pip install -e .
62
-
63
-
64
- pip install twine build
65
- rm -rf dist/
66
- python -m build
67
-
68
- python -m twine upload dist/*
69
-
70
- -->
dwani-0.1.4/README.md DELETED
@@ -1,34 +0,0 @@
1
- # dwani.ai - python library
2
-
3
-
4
- ```bash
5
- pip install dwani
6
- ```
7
-
8
-
9
-
10
- ```python
11
- import dwani
12
- import os
13
-
14
- dwani.api_key = os.getenv("DWANI_API_KEY")
15
-
16
- dwani.api_base = os.getenv("DWANI_API_BASE_URL")
17
-
18
- resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
19
- print(resp)
20
- ```
21
-
22
-
23
- <!--
24
- ## local development
25
- pip install -e .
26
-
27
-
28
- pip install twine build
29
- rm -rf dist/
30
- python -m build
31
-
32
- python -m twine upload dist/*
33
-
34
- -->
@@ -1,41 +0,0 @@
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("DWANI_API_KEY")
8
- self.api_base = api_base or os.getenv("DWANI_API_BASE_URL", "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, src_lang, tgt_lang, **kwargs):
16
- from .chat import chat_create
17
- return chat_create(self, prompt, src_lang, tgt_lang, **kwargs)
18
-
19
- def speech(self, *args, **kwargs):
20
- from .audio import audio_speech
21
- return audio_speech(self, *args, **kwargs)
22
-
23
- def caption(self, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda"):
24
- from .vision import vision_caption
25
- return vision_caption(self, file_path, query, src_lang, tgt_lang)
26
-
27
- def transcribe(self, *args, **kwargs):
28
- from .asr import asr_transcribe
29
- return asr_transcribe(self, *args, **kwargs)
30
- def document_ocr(self, file_path, language=None):
31
- from .docs import document_ocr
32
- return document_ocr(self, file_path, language)
33
-
34
- def document_translate(self, file_path, src_lang, tgt_lang):
35
- from .docs import document_translate
36
- return document_translate(self, file_path, src_lang, tgt_lang)
37
-
38
- def document_summarize(self, file_path, language=None):
39
- from .docs import document_summarize
40
- return document_summarize(self, file_path, language)
41
-
dwani-0.1.4/dwani/docs.py DELETED
@@ -1,70 +0,0 @@
1
- import requests
2
- from .exceptions import DhwaniAPIError
3
-
4
- def document_ocr(client, file_path, language=None):
5
- """OCR a document (image/PDF) and return extracted text."""
6
- with open(file_path, "rb") as f:
7
- files = {"file": f}
8
- data = {}
9
- if language:
10
- data["language"] = language
11
- resp = requests.post(
12
- f"{client.api_base}/v1/document/ocr",
13
- headers=client._headers(),
14
- files=files,
15
- data=data
16
- )
17
- if resp.status_code != 200:
18
- raise DhwaniAPIError(resp)
19
- return resp.json()
20
-
21
- def document_translate(client, file_path, src_lang, tgt_lang):
22
- """Translate a document (image/PDF with text) from src_lang to tgt_lang."""
23
- with open(file_path, "rb") as f:
24
- files = {"file": f}
25
- data = {
26
- "src_lang": src_lang,
27
- "tgt_lang": tgt_lang
28
- }
29
- resp = requests.post(
30
- f"{client.api_base}/v1/document/translate",
31
- headers=client._headers(),
32
- files=files,
33
- data=data
34
- )
35
- if resp.status_code != 200:
36
- raise DhwaniAPIError(resp)
37
- return resp.json()
38
-
39
- def document_summarize(client, file_path, language=None):
40
- """Summarize a document (image/PDF/text)."""
41
- with open(file_path, "rb") as f:
42
- files = {"file": f}
43
- data = {}
44
- if language:
45
- data["language"] = language
46
- resp = requests.post(
47
- f"{client.api_base}/v1/document/summarize",
48
- headers=client._headers(),
49
- files=files,
50
- data=data
51
- )
52
- if resp.status_code != 200:
53
- raise DhwaniAPIError(resp)
54
- return resp.json()
55
-
56
- class Documents:
57
- @staticmethod
58
- def ocr(file_path, language=None):
59
- from . import _get_client
60
- return _get_client().document_ocr(file_path, language)
61
-
62
- @staticmethod
63
- def translate(file_path, src_lang, tgt_lang):
64
- from . import _get_client
65
- return _get_client().document_translate(file_path, src_lang, tgt_lang)
66
-
67
- @staticmethod
68
- def summarize(file_path, language=None):
69
- from . import _get_client
70
- return _get_client().document_summarize(file_path, language)
@@ -1,70 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: dwani
3
- Version: 0.1.4
4
- Summary: Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
5
- Author-email: sachin <python@dwani.ai>
6
- License: MIT License
7
-
8
- Copyright (c) 2025 Sachin Shetty
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
29
- Project-URL: Source, https://github.com/dwani-ai/dwani-python
30
- Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
31
- Requires-Python: >=3.8
32
- Description-Content-Type: text/markdown
33
- License-File: LICENSE
34
- Requires-Dist: requests>=2.25.0
35
- Dynamic: license-file
36
-
37
- # dwani.ai - python library
38
-
39
-
40
- ```bash
41
- pip install dwani
42
- ```
43
-
44
-
45
-
46
- ```python
47
- import dwani
48
- import os
49
-
50
- dwani.api_key = os.getenv("DWANI_API_KEY")
51
-
52
- dwani.api_base = os.getenv("DWANI_API_BASE_URL")
53
-
54
- resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
55
- print(resp)
56
- ```
57
-
58
-
59
- <!--
60
- ## local development
61
- pip install -e .
62
-
63
-
64
- pip install twine build
65
- rm -rf dist/
66
- python -m build
67
-
68
- python -m twine upload dist/*
69
-
70
- -->
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes