dwani 0.1.3__tar.gz → 0.1.5__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.3 → dwani-0.1.5}/PKG-INFO +46 -7
- dwani-0.1.5/README.md +73 -0
- dwani-0.1.3/dwani/vision.py → dwani-0.1.5/dwani/asr.py +7 -8
- {dwani-0.1.3 → dwani-0.1.5}/dwani/audio.py +6 -6
- {dwani-0.1.3 → dwani-0.1.5}/dwani/client.py +8 -4
- dwani-0.1.5/dwani/translate.py +29 -0
- dwani-0.1.5/dwani/vision.py +31 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani.egg-info/PKG-INFO +46 -7
- {dwani-0.1.3 → dwani-0.1.5}/dwani.egg-info/SOURCES.txt +1 -0
- {dwani-0.1.3 → dwani-0.1.5}/pyproject.toml +3 -3
- dwani-0.1.3/README.md +0 -34
- dwani-0.1.3/dwani/asr.py +0 -37
- {dwani-0.1.3 → dwani-0.1.5}/LICENSE +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani/__init__.py +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani/chat.py +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani/docs.py +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani/exceptions.py +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani.egg-info/dependency_links.txt +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani.egg-info/requires.txt +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/dwani.egg-info/top_level.txt +0 -0
- {dwani-0.1.3 → dwani-0.1.5}/setup.cfg +0 -0
@@ -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.5
|
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
|
@@ -37,25 +37,64 @@ Dynamic: license-file
|
|
37
37
|
# dwani.ai - python library
|
38
38
|
|
39
39
|
|
40
|
+
### Install the library
|
40
41
|
```bash
|
41
42
|
pip install dwani
|
42
43
|
```
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
### Setup the credentials
|
46
46
|
```python
|
47
47
|
import dwani
|
48
48
|
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
|
-
|
55
|
+
### Examples
|
56
|
+
|
57
|
+
#### Text Query
|
58
|
+
```python
|
59
|
+
resp = dwani.Chat.create(prompt="Hello!", src_lang="eng_Latn", tgt_lang="kan_Knda")
|
55
60
|
print(resp)
|
56
61
|
```
|
57
62
|
|
63
|
+
#### Vision Query
|
64
|
+
```python
|
65
|
+
result = dwani.Vision.caption(
|
66
|
+
file_path="image.png",
|
67
|
+
query="Describe this logo",
|
68
|
+
src_lang="eng_Latn",
|
69
|
+
tgt_lang="kan_Knda"
|
70
|
+
)
|
71
|
+
print(result)
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Speech to Text - Automatic Speech Recognition (ASR)
|
75
|
+
```python
|
76
|
+
result = dwani.ASR.transcribe(file_path="kannada_sample.wav", language="kannada")
|
77
|
+
print(result)
|
78
|
+
```
|
79
|
+
|
80
|
+
#### Text to Speech - Speech Synthesis
|
81
|
+
|
82
|
+
```python
|
83
|
+
response = dwani.Audio.speech(input="ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು", response_format="mp3")
|
84
|
+
with open("output.mp3", "wb") as f:
|
85
|
+
f.write(response)
|
86
|
+
```
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
- Website -> [dwani.ai](https://dwani.ai)
|
91
|
+
|
92
|
+
|
58
93
|
|
94
|
+
#### Contact
|
95
|
+
- For any questions or issues, please open an issue on GitHub or contact us via email.
|
96
|
+
- For collaborations
|
97
|
+
- Join the discord group - [invite link](https://discord.gg/WZMCerEZ2P)
|
59
98
|
<!--
|
60
99
|
## local development
|
61
100
|
pip install -e .
|
dwani-0.1.5/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
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
|
+
|
27
|
+
#### Vision Query
|
28
|
+
```python
|
29
|
+
result = dwani.Vision.caption(
|
30
|
+
file_path="image.png",
|
31
|
+
query="Describe this logo",
|
32
|
+
src_lang="eng_Latn",
|
33
|
+
tgt_lang="kan_Knda"
|
34
|
+
)
|
35
|
+
print(result)
|
36
|
+
```
|
37
|
+
|
38
|
+
#### Speech to Text - Automatic Speech Recognition (ASR)
|
39
|
+
```python
|
40
|
+
result = dwani.ASR.transcribe(file_path="kannada_sample.wav", language="kannada")
|
41
|
+
print(result)
|
42
|
+
```
|
43
|
+
|
44
|
+
#### Text to Speech - Speech Synthesis
|
45
|
+
|
46
|
+
```python
|
47
|
+
response = dwani.Audio.speech(input="ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು", response_format="mp3")
|
48
|
+
with open("output.mp3", "wb") as f:
|
49
|
+
f.write(response)
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
- Website -> [dwani.ai](https://dwani.ai)
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
#### Contact
|
59
|
+
- For any questions or issues, please open an issue on GitHub or contact us via email.
|
60
|
+
- For collaborations
|
61
|
+
- Join the discord group - [invite link](https://discord.gg/WZMCerEZ2P)
|
62
|
+
<!--
|
63
|
+
## local development
|
64
|
+
pip install -e .
|
65
|
+
|
66
|
+
|
67
|
+
pip install twine build
|
68
|
+
rm -rf dist/
|
69
|
+
python -m build
|
70
|
+
|
71
|
+
python -m twine upload dist/*
|
72
|
+
|
73
|
+
-->
|
@@ -1,21 +1,20 @@
|
|
1
1
|
from .exceptions import DhwaniAPIError
|
2
2
|
import requests
|
3
|
-
def
|
3
|
+
def asr_transcribe(client, file_path, language):
|
4
4
|
with open(file_path, "rb") as f:
|
5
5
|
files = {"file": f}
|
6
|
-
data = {"length": length}
|
7
6
|
resp = requests.post(
|
8
|
-
f"{client.api_base}/
|
7
|
+
f"{client.api_base}/v1/transcribe/?language={language}",
|
9
8
|
headers=client._headers(),
|
10
|
-
files=files
|
11
|
-
data=data
|
9
|
+
files=files
|
12
10
|
)
|
13
11
|
if resp.status_code != 200:
|
14
12
|
raise DhwaniAPIError(resp)
|
15
13
|
return resp.json()
|
16
14
|
|
17
|
-
class
|
15
|
+
class ASR:
|
18
16
|
@staticmethod
|
19
|
-
def
|
17
|
+
def transcribe(*args, **kwargs):
|
20
18
|
from . import _get_client
|
21
|
-
return _get_client().
|
19
|
+
return _get_client().transcribe(*args, **kwargs)
|
20
|
+
|
@@ -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:
|
@@ -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:8000")
|
9
9
|
if not self.api_key:
|
10
10
|
raise ValueError("DHWANI_API_KEY not set")
|
11
11
|
|
@@ -15,19 +15,23 @@ class DhwaniClient:
|
|
15
15
|
def chat(self, prompt, src_lang, tgt_lang, **kwargs):
|
16
16
|
from .chat import chat_create
|
17
17
|
return chat_create(self, prompt, src_lang, tgt_lang, **kwargs)
|
18
|
-
|
18
|
+
|
19
|
+
def translate(self, sentences, src_lang, tgt_lang, **kwargs):
|
20
|
+
from .translate import run_translate
|
21
|
+
return run_translate(self, sentences=sentences,src_lang= src_lang, tgt_lang=tgt_lang, **kwargs)
|
19
22
|
|
20
23
|
def speech(self, *args, **kwargs):
|
21
24
|
from .audio import audio_speech
|
22
25
|
return audio_speech(self, *args, **kwargs)
|
23
26
|
|
24
|
-
def caption(self,
|
27
|
+
def caption(self, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda"):
|
25
28
|
from .vision import vision_caption
|
26
|
-
return vision_caption(self,
|
29
|
+
return vision_caption(self, file_path, query, src_lang, tgt_lang)
|
27
30
|
|
28
31
|
def transcribe(self, *args, **kwargs):
|
29
32
|
from .asr import asr_transcribe
|
30
33
|
return asr_transcribe(self, *args, **kwargs)
|
34
|
+
|
31
35
|
def document_ocr(self, file_path, language=None):
|
32
36
|
from .docs import document_ocr
|
33
37
|
return document_ocr(self, file_path, language)
|
@@ -0,0 +1,29 @@
|
|
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 translate(sentence, src_lang, tgt_lang, **kwargs):
|
24
|
+
from . import _get_client
|
25
|
+
client = _get_client()
|
26
|
+
# Ensure sentences is always a list
|
27
|
+
response = run_translate(client, [sentence], src_lang, tgt_lang, **kwargs)
|
28
|
+
# Return the first translation, or None if not found
|
29
|
+
return response.get("translations", [None])[0]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from .exceptions import DhwaniAPIError
|
2
|
+
import requests
|
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
|
+
}
|
14
|
+
with open(file_path, "rb") as f:
|
15
|
+
files = {"file": (file_path, f, "image/png")}
|
16
|
+
data = {"query": query}
|
17
|
+
resp = requests.post(
|
18
|
+
url,
|
19
|
+
headers=headers,
|
20
|
+
files=files,
|
21
|
+
data=data
|
22
|
+
)
|
23
|
+
if resp.status_code != 200:
|
24
|
+
raise DhwaniAPIError(resp)
|
25
|
+
return resp.json()
|
26
|
+
|
27
|
+
class Vision:
|
28
|
+
@staticmethod
|
29
|
+
def caption(*args, **kwargs):
|
30
|
+
from . import _get_client
|
31
|
+
return _get_client().caption(*args, **kwargs)
|
@@ -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.5
|
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
|
@@ -37,25 +37,64 @@ Dynamic: license-file
|
|
37
37
|
# dwani.ai - python library
|
38
38
|
|
39
39
|
|
40
|
+
### Install the library
|
40
41
|
```bash
|
41
42
|
pip install dwani
|
42
43
|
```
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
### Setup the credentials
|
46
46
|
```python
|
47
47
|
import dwani
|
48
48
|
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
|
-
|
55
|
+
### Examples
|
56
|
+
|
57
|
+
#### Text Query
|
58
|
+
```python
|
59
|
+
resp = dwani.Chat.create(prompt="Hello!", src_lang="eng_Latn", tgt_lang="kan_Knda")
|
55
60
|
print(resp)
|
56
61
|
```
|
57
62
|
|
63
|
+
#### Vision Query
|
64
|
+
```python
|
65
|
+
result = dwani.Vision.caption(
|
66
|
+
file_path="image.png",
|
67
|
+
query="Describe this logo",
|
68
|
+
src_lang="eng_Latn",
|
69
|
+
tgt_lang="kan_Knda"
|
70
|
+
)
|
71
|
+
print(result)
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Speech to Text - Automatic Speech Recognition (ASR)
|
75
|
+
```python
|
76
|
+
result = dwani.ASR.transcribe(file_path="kannada_sample.wav", language="kannada")
|
77
|
+
print(result)
|
78
|
+
```
|
79
|
+
|
80
|
+
#### Text to Speech - Speech Synthesis
|
81
|
+
|
82
|
+
```python
|
83
|
+
response = dwani.Audio.speech(input="ಕರ್ನಾಟಕ ದ ರಾಜಧಾನಿ ಯಾವುದು", response_format="mp3")
|
84
|
+
with open("output.mp3", "wb") as f:
|
85
|
+
f.write(response)
|
86
|
+
```
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
- Website -> [dwani.ai](https://dwani.ai)
|
91
|
+
|
92
|
+
|
58
93
|
|
94
|
+
#### Contact
|
95
|
+
- For any questions or issues, please open an issue on GitHub or contact us via email.
|
96
|
+
- For collaborations
|
97
|
+
- Join the discord group - [invite link](https://discord.gg/WZMCerEZ2P)
|
59
98
|
<!--
|
60
99
|
## local development
|
61
100
|
pip install -e .
|
@@ -4,14 +4,14 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "dwani"
|
7
|
-
version = "0.1.
|
8
|
-
description = "Multimodal
|
7
|
+
version = "0.1.5"
|
8
|
+
description = "Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)"
|
9
9
|
authors = [
|
10
10
|
{ name="sachin", email="python@dwani.ai" }
|
11
11
|
]
|
12
12
|
readme = "README.md"
|
13
13
|
license = { file = "LICENSE" }
|
14
|
-
requires-python = ">=3.
|
14
|
+
requires-python = ">=3.8"
|
15
15
|
|
16
16
|
dependencies = [
|
17
17
|
"requests>=2.25.0",
|
dwani-0.1.3/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")
|
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
|
-
-->
|
dwani-0.1.3/dwani/asr.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
from .exceptions import DhwaniAPIError
|
2
|
-
import requests
|
3
|
-
def asr_transcribe(client, file_path, language):
|
4
|
-
with open(file_path, "rb") as f:
|
5
|
-
files = {"file": f}
|
6
|
-
resp = requests.post(
|
7
|
-
f"{client.api_base}/transcribe/?language={language}",
|
8
|
-
headers=client._headers(),
|
9
|
-
files=files
|
10
|
-
)
|
11
|
-
if resp.status_code != 200:
|
12
|
-
raise DhwaniAPIError(resp)
|
13
|
-
return resp.json()
|
14
|
-
|
15
|
-
class ASR:
|
16
|
-
@staticmethod
|
17
|
-
def transcribe(*args, **kwargs):
|
18
|
-
from . import _get_client
|
19
|
-
return _get_client().transcribe(*args, **kwargs)
|
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
|
-
'''
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|