pipecat-bodhan-tts 0.1.0__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.
- pipecat_bodhan_tts-0.1.0/.env.example +3 -0
- pipecat_bodhan_tts-0.1.0/.github/workflows/ci.yml +22 -0
- pipecat_bodhan_tts-0.1.0/.gitignore +7 -0
- pipecat_bodhan_tts-0.1.0/CHANGELOG.md +8 -0
- pipecat_bodhan_tts-0.1.0/LICENSE +24 -0
- pipecat_bodhan_tts-0.1.0/PKG-INFO +182 -0
- pipecat_bodhan_tts-0.1.0/README.md +166 -0
- pipecat_bodhan_tts-0.1.0/examples/bodhan_voice_bot.py +132 -0
- pipecat_bodhan_tts-0.1.0/pyproject.toml +60 -0
- pipecat_bodhan_tts-0.1.0/src/pipecat_bodhan_tts/__init__.py +27 -0
- pipecat_bodhan_tts-0.1.0/src/pipecat_bodhan_tts/tts.py +400 -0
- pipecat_bodhan_tts-0.1.0/tests/test_live.py +43 -0
- pipecat_bodhan_tts-0.1.0/tests/test_tts.py +294 -0
- pipecat_bodhan_tts-0.1.0/uv.lock +2175 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v6
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- run: uv sync --group dev
|
|
20
|
+
- run: uv run ruff check
|
|
21
|
+
- run: uv run ruff format --check
|
|
22
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, pipecat-bodhan-tts contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pipecat-bodhan-tts
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Bodhan AI text-to-speech (indic-speak) service for Pipecat
|
|
5
|
+
Project-URL: Source, https://github.com/Shridhar7-8/pipecat-bodhan-tts
|
|
6
|
+
Author-email: Shridhar7-8 <shridharkur@gmail.com>
|
|
7
|
+
License-Expression: BSD-2-Clause
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: bodhan,indic,pipecat,text-to-speech,tts,voice-ai
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Requires-Dist: aiohttp<4,>=3.14.4
|
|
14
|
+
Requires-Dist: pipecat-ai<2,>=1.18.0
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# pipecat-bodhan-tts
|
|
18
|
+
|
|
19
|
+
[Bodhan AI](https://bodhan.ai) text-to-speech for [Pipecat](https://github.com/pipecat-ai/pipecat).
|
|
20
|
+
`BodhanHttpTTSService` speaks with Bodhan's `indic-speak` model: English and 22 Indian
|
|
21
|
+
languages, 45 voices and 14 delivery styles.
|
|
22
|
+
|
|
23
|
+
Tested with Pipecat v1.18.0 on Python 3.11–3.13.
|
|
24
|
+
|
|
25
|
+
> Community-maintained integration; not an official Bodhan AI or Pipecat product.
|
|
26
|
+
|
|
27
|
+
## How it works
|
|
28
|
+
|
|
29
|
+
`BodhanHttpTTSService` is a Pipecat `TTSService`. Pipecat aggregates the LLM's text into
|
|
30
|
+
sentences; the service sends each sentence to Bodhan's `/v1/audio/speech` endpoint, receives a
|
|
31
|
+
24 kHz mono WAV clip, and pushes its audio. Pipecat resamples it to the pipeline's output rate.
|
|
32
|
+
|
|
33
|
+
- **Not streaming.** Bodhan generates a whole clip before sending any of it, at roughly real
|
|
34
|
+
time: a two-second sentence takes about two seconds before its first audio. Keep Pipecat's
|
|
35
|
+
default sentence aggregation, so the bot starts speaking after the first sentence rather
|
|
36
|
+
than the whole reply.
|
|
37
|
+
- **Interruptions.** When the user interrupts, Pipecat drops the audio not yet played and the
|
|
38
|
+
request in flight is abandoned. Bodhan may still finish generating that clip.
|
|
39
|
+
- **Voices and languages are independent.** Each voice was recorded in one language but can
|
|
40
|
+
speak any supported language.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install pipecat-bodhan-tts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Get an API key from the [Bodhan console](https://console.bodhan.ai/dashboard/). A key is
|
|
49
|
+
scoped to its models, so use one with access to `indic-speak`.
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import os
|
|
55
|
+
|
|
56
|
+
from pipecat.transcriptions.language import Language
|
|
57
|
+
from pipecat_bodhan_tts import BodhanHttpTTSService
|
|
58
|
+
|
|
59
|
+
tts = BodhanHttpTTSService(
|
|
60
|
+
api_key=os.environ["BODHAN_TTS_API_KEY"],
|
|
61
|
+
settings=BodhanHttpTTSService.Settings(
|
|
62
|
+
voice="Kavya",
|
|
63
|
+
language=Language.HI,
|
|
64
|
+
style="Customer Care",
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
pipeline = Pipeline(
|
|
69
|
+
[transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator]
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Change voice, language or style mid-conversation with a settings frame:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
await worker.queue_frame(
|
|
77
|
+
TTSUpdateSettingsFrame(
|
|
78
|
+
delta=BodhanHttpTTSService.Settings(voice="Anitha", language=Language.TA)
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Parameters
|
|
84
|
+
|
|
85
|
+
| Parameter | Default | Description |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| `api_key` | required | Bodhan API key with access to `indic-speak`. |
|
|
88
|
+
| `aiohttp_session` | `None` | Session to send requests with. When omitted, the service creates one and closes it at cleanup. |
|
|
89
|
+
| `base_url` | `https://api.bodhan.ai/v1` | Bodhan API base URL. |
|
|
90
|
+
| `request_timeout_secs` | `30.0` | Timeout for each synthesis request. |
|
|
91
|
+
| `sample_rate` | pipeline rate | Output sample rate; Bodhan's 24 kHz audio is resampled to it. |
|
|
92
|
+
| `settings` | see below | `BodhanHttpTTSService.Settings`, updatable at runtime with `TTSUpdateSettingsFrame`. |
|
|
93
|
+
|
|
94
|
+
| Setting | Default | Description |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `model` | `indic-speak` | Bodhan speech model. |
|
|
97
|
+
| `voice` | `Kavya` | A Bodhan voice name. |
|
|
98
|
+
| `language` | Hindi | A Pipecat `Language` or a Bodhan code. Regional variants resolve to the base language (`ta-IN` → `ta`). |
|
|
99
|
+
| `style` | `None` (neutral) | A delivery style. |
|
|
100
|
+
|
|
101
|
+
### Languages
|
|
102
|
+
|
|
103
|
+
`as` Assamese, `bn` Bengali, `brx` Bodo, `doi` Dogri, `en` English, `gu` Gujarati,
|
|
104
|
+
`hi` Hindi, `kn` Kannada, `kok` Konkani, `ks` Kashmiri, `mai` Maithili, `ml` Malayalam,
|
|
105
|
+
`mni` Manipuri, `mr` Marathi, `ne` Nepali, `or` Odia, `pa` Punjabi, `sa` Sanskrit,
|
|
106
|
+
`sat` Santali, `sd` Sindhi, `ta` Tamil, `te` Telugu, `ur` Urdu.
|
|
107
|
+
|
|
108
|
+
An unsupported language raises `ValueError` at construction; in a runtime update it is
|
|
109
|
+
logged, and the current language is kept.
|
|
110
|
+
|
|
111
|
+
### Voices
|
|
112
|
+
|
|
113
|
+
| Recorded in | Female | Male |
|
|
114
|
+
| --- | --- | --- |
|
|
115
|
+
| Assamese | Prastuti | Ankur |
|
|
116
|
+
| Bengali | Ishita | Sourav |
|
|
117
|
+
| Bodo | Gwrbw | Sansuma |
|
|
118
|
+
| Dogri | Preeti | Sham |
|
|
119
|
+
| Gujarati | Dhara | Parth |
|
|
120
|
+
| Hindi | Kavya, Suhani | Amit |
|
|
121
|
+
| Kannada | Deepika | Adarsh |
|
|
122
|
+
| Konkani | Anjali | Sandeep |
|
|
123
|
+
| Kashmiri | Zoon | Ishfaq |
|
|
124
|
+
| Maithili | Vaidehi | Madhukar |
|
|
125
|
+
| Malayalam | Lakshmi | Kiran |
|
|
126
|
+
| Manipuri | Thoibi | Chaoba |
|
|
127
|
+
| Marathi | Anagha | Chinmay |
|
|
128
|
+
| Nepali | Srijana | Sagar |
|
|
129
|
+
| Odia | Itishree | Akash |
|
|
130
|
+
| Punjabi | Kaur | Manpreet |
|
|
131
|
+
| Sanskrit | Bharati | Aryaman |
|
|
132
|
+
| Santali | Phulmani | Sibu |
|
|
133
|
+
| Sindhi | Moomal | Rano |
|
|
134
|
+
| Tamil | Anitha | Arun |
|
|
135
|
+
| Telugu | Sravani | Vamsi |
|
|
136
|
+
| Urdu | Saba | Zaid |
|
|
137
|
+
|
|
138
|
+
### Styles
|
|
139
|
+
|
|
140
|
+
`AIR style news`, `Customer Care`, `TV style news`, `advertisements`, `anger`,
|
|
141
|
+
`children's stories`, `disgust`, `educational lecture`, `fear`, `happy`, `news`, `sad`,
|
|
142
|
+
`single person narration audiobook`, `surprise`.
|
|
143
|
+
|
|
144
|
+
### Errors
|
|
145
|
+
|
|
146
|
+
A failed request becomes an `ErrorFrame` carrying a `BodhanAPIError` with the HTTP status,
|
|
147
|
+
which Pipecat uses to classify it: 401 and 403 mark the service unusable, and 429 is reported
|
|
148
|
+
as a rate limit. The service doesn't retry.
|
|
149
|
+
|
|
150
|
+
Bodhan answers an unknown voice or style with a bare `500 Internal server error`. The service
|
|
151
|
+
warns when a voice or style isn't in the lists above, and names it in the error when Bodhan
|
|
152
|
+
returns a 500.
|
|
153
|
+
|
|
154
|
+
## Example
|
|
155
|
+
|
|
156
|
+
[`examples/bodhan_voice_bot.py`](https://github.com/Shridhar7-8/pipecat-bodhan-tts/blob/main/examples/bodhan_voice_bot.py) is a Hindi voice agent that
|
|
157
|
+
uses Bodhan for both speech directions and OpenAI for the conversation:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pip install pipecat-bodhan-stt pipecat-bodhan-tts \
|
|
161
|
+
"pipecat-ai[openai,silero,webrtc,runner]" python-dotenv
|
|
162
|
+
cp .env.example .env # fill in BODHAN_STT_API_KEY, BODHAN_TTS_API_KEY, OPENAI_API_KEY
|
|
163
|
+
python examples/bodhan_voice_bot.py
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Open http://localhost:7860 and talk. Set `BOT_LANGUAGE=ta BOT_VOICE=Anitha` for Tamil.
|
|
167
|
+
|
|
168
|
+
Speech-to-text is in the companion package
|
|
169
|
+
[pipecat-bodhan-stt](https://github.com/Shridhar7-8/pipecat-bodhan-stt).
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
uv sync --group dev
|
|
175
|
+
uv run pytest # unit tests, against a mocked Bodhan API
|
|
176
|
+
uv run ruff check && uv run ruff format --check
|
|
177
|
+
BODHAN_TTS_API_KEY=... uv run pytest -m live # calls the real API; billed
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
BSD 2-Clause, the same as Pipecat. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# pipecat-bodhan-tts
|
|
2
|
+
|
|
3
|
+
[Bodhan AI](https://bodhan.ai) text-to-speech for [Pipecat](https://github.com/pipecat-ai/pipecat).
|
|
4
|
+
`BodhanHttpTTSService` speaks with Bodhan's `indic-speak` model: English and 22 Indian
|
|
5
|
+
languages, 45 voices and 14 delivery styles.
|
|
6
|
+
|
|
7
|
+
Tested with Pipecat v1.18.0 on Python 3.11–3.13.
|
|
8
|
+
|
|
9
|
+
> Community-maintained integration; not an official Bodhan AI or Pipecat product.
|
|
10
|
+
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
`BodhanHttpTTSService` is a Pipecat `TTSService`. Pipecat aggregates the LLM's text into
|
|
14
|
+
sentences; the service sends each sentence to Bodhan's `/v1/audio/speech` endpoint, receives a
|
|
15
|
+
24 kHz mono WAV clip, and pushes its audio. Pipecat resamples it to the pipeline's output rate.
|
|
16
|
+
|
|
17
|
+
- **Not streaming.** Bodhan generates a whole clip before sending any of it, at roughly real
|
|
18
|
+
time: a two-second sentence takes about two seconds before its first audio. Keep Pipecat's
|
|
19
|
+
default sentence aggregation, so the bot starts speaking after the first sentence rather
|
|
20
|
+
than the whole reply.
|
|
21
|
+
- **Interruptions.** When the user interrupts, Pipecat drops the audio not yet played and the
|
|
22
|
+
request in flight is abandoned. Bodhan may still finish generating that clip.
|
|
23
|
+
- **Voices and languages are independent.** Each voice was recorded in one language but can
|
|
24
|
+
speak any supported language.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install pipecat-bodhan-tts
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Get an API key from the [Bodhan console](https://console.bodhan.ai/dashboard/). A key is
|
|
33
|
+
scoped to its models, so use one with access to `indic-speak`.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import os
|
|
39
|
+
|
|
40
|
+
from pipecat.transcriptions.language import Language
|
|
41
|
+
from pipecat_bodhan_tts import BodhanHttpTTSService
|
|
42
|
+
|
|
43
|
+
tts = BodhanHttpTTSService(
|
|
44
|
+
api_key=os.environ["BODHAN_TTS_API_KEY"],
|
|
45
|
+
settings=BodhanHttpTTSService.Settings(
|
|
46
|
+
voice="Kavya",
|
|
47
|
+
language=Language.HI,
|
|
48
|
+
style="Customer Care",
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
pipeline = Pipeline(
|
|
53
|
+
[transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator]
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Change voice, language or style mid-conversation with a settings frame:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
await worker.queue_frame(
|
|
61
|
+
TTSUpdateSettingsFrame(
|
|
62
|
+
delta=BodhanHttpTTSService.Settings(voice="Anitha", language=Language.TA)
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Parameters
|
|
68
|
+
|
|
69
|
+
| Parameter | Default | Description |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| `api_key` | required | Bodhan API key with access to `indic-speak`. |
|
|
72
|
+
| `aiohttp_session` | `None` | Session to send requests with. When omitted, the service creates one and closes it at cleanup. |
|
|
73
|
+
| `base_url` | `https://api.bodhan.ai/v1` | Bodhan API base URL. |
|
|
74
|
+
| `request_timeout_secs` | `30.0` | Timeout for each synthesis request. |
|
|
75
|
+
| `sample_rate` | pipeline rate | Output sample rate; Bodhan's 24 kHz audio is resampled to it. |
|
|
76
|
+
| `settings` | see below | `BodhanHttpTTSService.Settings`, updatable at runtime with `TTSUpdateSettingsFrame`. |
|
|
77
|
+
|
|
78
|
+
| Setting | Default | Description |
|
|
79
|
+
| --- | --- | --- |
|
|
80
|
+
| `model` | `indic-speak` | Bodhan speech model. |
|
|
81
|
+
| `voice` | `Kavya` | A Bodhan voice name. |
|
|
82
|
+
| `language` | Hindi | A Pipecat `Language` or a Bodhan code. Regional variants resolve to the base language (`ta-IN` → `ta`). |
|
|
83
|
+
| `style` | `None` (neutral) | A delivery style. |
|
|
84
|
+
|
|
85
|
+
### Languages
|
|
86
|
+
|
|
87
|
+
`as` Assamese, `bn` Bengali, `brx` Bodo, `doi` Dogri, `en` English, `gu` Gujarati,
|
|
88
|
+
`hi` Hindi, `kn` Kannada, `kok` Konkani, `ks` Kashmiri, `mai` Maithili, `ml` Malayalam,
|
|
89
|
+
`mni` Manipuri, `mr` Marathi, `ne` Nepali, `or` Odia, `pa` Punjabi, `sa` Sanskrit,
|
|
90
|
+
`sat` Santali, `sd` Sindhi, `ta` Tamil, `te` Telugu, `ur` Urdu.
|
|
91
|
+
|
|
92
|
+
An unsupported language raises `ValueError` at construction; in a runtime update it is
|
|
93
|
+
logged, and the current language is kept.
|
|
94
|
+
|
|
95
|
+
### Voices
|
|
96
|
+
|
|
97
|
+
| Recorded in | Female | Male |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| Assamese | Prastuti | Ankur |
|
|
100
|
+
| Bengali | Ishita | Sourav |
|
|
101
|
+
| Bodo | Gwrbw | Sansuma |
|
|
102
|
+
| Dogri | Preeti | Sham |
|
|
103
|
+
| Gujarati | Dhara | Parth |
|
|
104
|
+
| Hindi | Kavya, Suhani | Amit |
|
|
105
|
+
| Kannada | Deepika | Adarsh |
|
|
106
|
+
| Konkani | Anjali | Sandeep |
|
|
107
|
+
| Kashmiri | Zoon | Ishfaq |
|
|
108
|
+
| Maithili | Vaidehi | Madhukar |
|
|
109
|
+
| Malayalam | Lakshmi | Kiran |
|
|
110
|
+
| Manipuri | Thoibi | Chaoba |
|
|
111
|
+
| Marathi | Anagha | Chinmay |
|
|
112
|
+
| Nepali | Srijana | Sagar |
|
|
113
|
+
| Odia | Itishree | Akash |
|
|
114
|
+
| Punjabi | Kaur | Manpreet |
|
|
115
|
+
| Sanskrit | Bharati | Aryaman |
|
|
116
|
+
| Santali | Phulmani | Sibu |
|
|
117
|
+
| Sindhi | Moomal | Rano |
|
|
118
|
+
| Tamil | Anitha | Arun |
|
|
119
|
+
| Telugu | Sravani | Vamsi |
|
|
120
|
+
| Urdu | Saba | Zaid |
|
|
121
|
+
|
|
122
|
+
### Styles
|
|
123
|
+
|
|
124
|
+
`AIR style news`, `Customer Care`, `TV style news`, `advertisements`, `anger`,
|
|
125
|
+
`children's stories`, `disgust`, `educational lecture`, `fear`, `happy`, `news`, `sad`,
|
|
126
|
+
`single person narration audiobook`, `surprise`.
|
|
127
|
+
|
|
128
|
+
### Errors
|
|
129
|
+
|
|
130
|
+
A failed request becomes an `ErrorFrame` carrying a `BodhanAPIError` with the HTTP status,
|
|
131
|
+
which Pipecat uses to classify it: 401 and 403 mark the service unusable, and 429 is reported
|
|
132
|
+
as a rate limit. The service doesn't retry.
|
|
133
|
+
|
|
134
|
+
Bodhan answers an unknown voice or style with a bare `500 Internal server error`. The service
|
|
135
|
+
warns when a voice or style isn't in the lists above, and names it in the error when Bodhan
|
|
136
|
+
returns a 500.
|
|
137
|
+
|
|
138
|
+
## Example
|
|
139
|
+
|
|
140
|
+
[`examples/bodhan_voice_bot.py`](https://github.com/Shridhar7-8/pipecat-bodhan-tts/blob/main/examples/bodhan_voice_bot.py) is a Hindi voice agent that
|
|
141
|
+
uses Bodhan for both speech directions and OpenAI for the conversation:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install pipecat-bodhan-stt pipecat-bodhan-tts \
|
|
145
|
+
"pipecat-ai[openai,silero,webrtc,runner]" python-dotenv
|
|
146
|
+
cp .env.example .env # fill in BODHAN_STT_API_KEY, BODHAN_TTS_API_KEY, OPENAI_API_KEY
|
|
147
|
+
python examples/bodhan_voice_bot.py
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Open http://localhost:7860 and talk. Set `BOT_LANGUAGE=ta BOT_VOICE=Anitha` for Tamil.
|
|
151
|
+
|
|
152
|
+
Speech-to-text is in the companion package
|
|
153
|
+
[pipecat-bodhan-stt](https://github.com/Shridhar7-8/pipecat-bodhan-stt).
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
uv sync --group dev
|
|
159
|
+
uv run pytest # unit tests, against a mocked Bodhan API
|
|
160
|
+
uv run ruff check && uv run ruff format --check
|
|
161
|
+
BODHAN_TTS_API_KEY=... uv run pytest -m live # calls the real API; billed
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
BSD 2-Clause, the same as Pipecat. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2026, pipecat-bodhan contributors
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: BSD 2-Clause License
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
"""A Hindi voice agent: Bodhan hears the user, an LLM answers, Bodhan speaks.
|
|
8
|
+
|
|
9
|
+
Requirements:
|
|
10
|
+
|
|
11
|
+
pip install pipecat-bodhan-stt pipecat-bodhan-tts \
|
|
12
|
+
"pipecat-ai[openai,silero,webrtc,runner]" python-dotenv
|
|
13
|
+
|
|
14
|
+
Environment (or a .env file): BODHAN_STT_API_KEY, BODHAN_TTS_API_KEY and
|
|
15
|
+
OPENAI_API_KEY. Set BOT_LANGUAGE to another Bodhan language code (e.g. "ta")
|
|
16
|
+
and BOT_VOICE to a voice (e.g. "Anitha") to change language.
|
|
17
|
+
|
|
18
|
+
Run it, then open http://localhost:7860 and talk to the bot:
|
|
19
|
+
|
|
20
|
+
python bodhan_voice_bot.py
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
|
|
25
|
+
from dotenv import load_dotenv
|
|
26
|
+
from loguru import logger
|
|
27
|
+
from pipecat.audio.vad.silero import SileroVADAnalyzer
|
|
28
|
+
from pipecat.frames.frames import LLMRunFrame
|
|
29
|
+
from pipecat.pipeline.pipeline import Pipeline
|
|
30
|
+
from pipecat.pipeline.worker import PipelineParams, PipelineWorker
|
|
31
|
+
from pipecat.processors.aggregators.llm_context import LLMContext
|
|
32
|
+
from pipecat.processors.aggregators.llm_response_universal import (
|
|
33
|
+
LLMContextAggregatorPair,
|
|
34
|
+
LLMUserAggregatorParams,
|
|
35
|
+
)
|
|
36
|
+
from pipecat.runner.types import RunnerArguments
|
|
37
|
+
from pipecat.runner.utils import create_transport
|
|
38
|
+
from pipecat.services.openai.llm import OpenAILLMService
|
|
39
|
+
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
|
40
|
+
from pipecat.workers.runner import WorkerRunner
|
|
41
|
+
|
|
42
|
+
from pipecat_bodhan_stt import BodhanSTTService
|
|
43
|
+
from pipecat_bodhan_tts import BodhanHttpTTSService
|
|
44
|
+
|
|
45
|
+
load_dotenv(override=True)
|
|
46
|
+
|
|
47
|
+
LANGUAGE = os.getenv("BOT_LANGUAGE", "hi")
|
|
48
|
+
VOICE = os.getenv("BOT_VOICE", "Kavya")
|
|
49
|
+
|
|
50
|
+
transport_params = {
|
|
51
|
+
"webrtc": lambda: TransportParams(audio_in_enabled=True, audio_out_enabled=True),
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|
56
|
+
stt = BodhanSTTService(
|
|
57
|
+
api_key=os.environ["BODHAN_STT_API_KEY"],
|
|
58
|
+
settings=BodhanSTTService.Settings(language=LANGUAGE),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
tts = BodhanHttpTTSService(
|
|
62
|
+
api_key=os.environ["BODHAN_TTS_API_KEY"],
|
|
63
|
+
settings=BodhanHttpTTSService.Settings(
|
|
64
|
+
voice=VOICE, language=LANGUAGE, style="Customer Care"
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
llm = OpenAILLMService(
|
|
69
|
+
api_key=os.environ["OPENAI_API_KEY"],
|
|
70
|
+
settings=OpenAILLMService.Settings(
|
|
71
|
+
system_instruction=(
|
|
72
|
+
f"You are a helpful customer-care assistant in a voice conversation. "
|
|
73
|
+
f"Always reply in the language with code '{LANGUAGE}', in its native "
|
|
74
|
+
f"script. Your replies are spoken aloud, so use short, plain sentences "
|
|
75
|
+
f"without emojis, lists or formatting."
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
context = LLMContext()
|
|
81
|
+
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
|
82
|
+
context,
|
|
83
|
+
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
pipeline = Pipeline(
|
|
87
|
+
[
|
|
88
|
+
transport.input(),
|
|
89
|
+
stt,
|
|
90
|
+
user_aggregator,
|
|
91
|
+
llm,
|
|
92
|
+
tts,
|
|
93
|
+
transport.output(),
|
|
94
|
+
assistant_aggregator,
|
|
95
|
+
]
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
worker = PipelineWorker(
|
|
99
|
+
pipeline,
|
|
100
|
+
params=PipelineParams(enable_metrics=True, enable_usage_metrics=True),
|
|
101
|
+
idle_timeout_secs=runner_args.pipeline_idle_timeout_secs,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
runner = WorkerRunner(handle_sigint=runner_args.handle_sigint)
|
|
105
|
+
await runner.add_workers(worker)
|
|
106
|
+
|
|
107
|
+
@transport.event_handler("on_client_connected")
|
|
108
|
+
async def on_client_connected(transport, client):
|
|
109
|
+
logger.info("Client connected")
|
|
110
|
+
context.add_message(
|
|
111
|
+
{"role": "developer", "content": "Greet the user and ask how you can help."}
|
|
112
|
+
)
|
|
113
|
+
await worker.queue_frames([LLMRunFrame()])
|
|
114
|
+
|
|
115
|
+
@transport.event_handler("on_client_disconnected")
|
|
116
|
+
async def on_client_disconnected(transport, client):
|
|
117
|
+
logger.info("Client disconnected")
|
|
118
|
+
await runner.cancel()
|
|
119
|
+
|
|
120
|
+
await runner.run()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
async def bot(runner_args: RunnerArguments):
|
|
124
|
+
"""Bot entry point for the Pipecat development runner."""
|
|
125
|
+
transport = await create_transport(runner_args, transport_params)
|
|
126
|
+
await run_bot(transport, runner_args)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
from pipecat.runner.run import main
|
|
131
|
+
|
|
132
|
+
main()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pipecat-bodhan-tts"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Bodhan AI text-to-speech (indic-speak) service for Pipecat"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "BSD-2-Clause"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Shridhar7-8", email = "shridharkur@gmail.com" }]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
keywords = ["pipecat", "bodhan", "tts", "text-to-speech", "indic", "voice-ai"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"pipecat-ai>=1.18.0,<2",
|
|
21
|
+
"aiohttp>=3.14.4,<4",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Source = "https://github.com/Shridhar7-8/pipecat-bodhan-tts"
|
|
26
|
+
|
|
27
|
+
[dependency-groups]
|
|
28
|
+
dev = [
|
|
29
|
+
"pytest>=8",
|
|
30
|
+
"pytest-asyncio>=1",
|
|
31
|
+
"pytest-aiohttp>=1",
|
|
32
|
+
"ruff>=0.12",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/pipecat_bodhan_tts"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
asyncio_mode = "auto"
|
|
40
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
41
|
+
testpaths = ["tests"]
|
|
42
|
+
markers = ["live: calls the real Bodhan API (needs BODHAN_TTS_API_KEY, billed)"]
|
|
43
|
+
addopts = "-m 'not live'"
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 100
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = ["D", "E", "F", "I", "UP"]
|
|
50
|
+
ignore = ["D105"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint.isort]
|
|
53
|
+
known-first-party = ["pipecat_bodhan_stt", "pipecat_bodhan_tts"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff.lint.pydocstyle]
|
|
56
|
+
convention = "google"
|
|
57
|
+
|
|
58
|
+
[tool.ruff.lint.per-file-ignores]
|
|
59
|
+
"tests/*" = ["D"]
|
|
60
|
+
"examples/*" = ["D"]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2026, pipecat-bodhan-tts contributors
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: BSD 2-Clause License
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
"""Bodhan text-to-speech for Pipecat."""
|
|
8
|
+
|
|
9
|
+
from pipecat_bodhan_tts.tts import (
|
|
10
|
+
BODHAN_TTS_LANGUAGES,
|
|
11
|
+
BODHAN_TTS_STYLES,
|
|
12
|
+
BODHAN_TTS_VOICES,
|
|
13
|
+
BodhanAPIError,
|
|
14
|
+
BodhanHttpTTSService,
|
|
15
|
+
BodhanTTSSettings,
|
|
16
|
+
bodhan_tts_language,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"BODHAN_TTS_LANGUAGES",
|
|
21
|
+
"BODHAN_TTS_STYLES",
|
|
22
|
+
"BODHAN_TTS_VOICES",
|
|
23
|
+
"BodhanAPIError",
|
|
24
|
+
"BodhanHttpTTSService",
|
|
25
|
+
"BodhanTTSSettings",
|
|
26
|
+
"bodhan_tts_language",
|
|
27
|
+
]
|