Bodhi Python SDK
Bodhi Python SDK provides a client for Navana's streaming speech recognition API.
Installation
pip install bodhi-sdk
Usage
To use the Bodhi Python SDK, follow these steps:
-
Installation: Install the SDK using pip:
pip install bodhi-sdk
-
Initialization: Create a
BodhiClientinstance with your API key and customer ID:from bodhi import BodhiClient client = BodhiClient(api_key="YOUR_API_KEY", customer_id="YOUR_CUSTOMER_ID")
-
Transcription: Use the client methods to transcribe audio. The SDK supports transcription from local files, remote URLs, and streams.
-
Local File Transcription:
config = TranscriptionConfig( model="hi-banking-v2-8khz", at_start_lid=False, # Enable language identification at start (default: False) transliterate=False, # Enable transliteration output (default: False) ) response = client.transcribe_local_file(audio_file_path, config=config) print(response.text)
-
Remote URL Transcription:
config = TranscriptionConfig( model="hi-banking-v2-8khz", at_start_lid=False, # Enable language identification at start (default: False) transliterate=False, # Enable transliteration output (default: False) ) response = client.transcribe_remote_url("http://example.com/audio.wav", config) print(response.text)
-
Streaming Transcription: Refer to the examples for detailed instructions on setting up streaming transcription.
-
-
Event Handling: You can register event listeners to handle different stages of the transcription process using the
client.onmethod and theLiveTranscriptionEventsenum. This is particularly useful for streaming and remote URL transcriptions where events are emitted asynchronously.from bodhi import LiveTranscriptionEvents async def on_transcript(response): print(f"Transcript: {response.text}") async def on_utterance_end(response): print(f"UtteranceEnd: {response}") async def on_speech_started(response): print(f"SpeechStarted: {response}") async def on_error(e): print(f"Error: {str(e)}") client.on(LiveTranscriptionEvents.Transcript, on_transcript) client.on(LiveTranscriptionEvents.UtteranceEnd, on_utterance_end) client.on(LiveTranscriptionEvents.SpeechStarted, on_speech_started) client.on(LiveTranscriptionEvents.Error, on_error)
Common events include:
LiveTranscriptionEvents.Transcript: Emitted when a new transcription segment is available.LiveTranscriptionEvents.UtteranceEnd: Emitted when an utterance is detected as complete.LiveTranscriptionEvents.SpeechStarted: Emitted when speech activity is detected.LiveTranscriptionEvents.Error: Emitted when an error occurs during transcription.LiveTranscriptionEvents.Close: Emitted when the WebSocket connection is closed.
Pipecat integration
Building a voice agent with Pipecat? Bodhi drops into the STT slot of a Pipecat pipeline:
pip install "bodhi-sdk[pipecat]"
import os
from pipecat.pipeline.pipeline import Pipeline
from bodhi.integrations.pipecat_stt import BodhiHotword, BodhiSTTService
stt = BodhiSTTService(
api_key=os.environ["BODHI_API_KEY"],
customer_id=os.environ["BODHI_CUSTOMER_ID"],
model="hi-general-v2-8khz",
settings=BodhiSTTService.Settings(
parse_number=True, # normalise numbers, dates, currency
endpoint_silence_duration=0.6, # server-side endpointing, 0.44-1.2s
hotwords=[BodhiHotword("बजाज फिनसर्व", 2.0)],
),
)
pipeline = Pipeline([
transport.input(),
stt,
context_aggregator.user(),
llm,
tts,
transport.output(),
])
That is the whole integration — api_key, customer_id and model are the only
required arguments, and url defaults to wss://bodhi.navana.ai. Bodhi's
partial results arrive as InterimTranscriptionFrames and its endpointed final
results as TranscriptionFrames, so interruption handling and turn taking work
exactly as they do with any other Pipecat STT service.
Maintained by Navana Tech, who build Bodhi.
Written for pipecat-ai 1.4 and verified on 1.4.0 and 1.8.1. Streaming and transcripts also work as far back as 1.0.0; switching model or hotwords at runtime needs 1.4+, since that is where Pipecat's reconnect hook arrived. Needs Python 3.10+, as Pipecat does.
If you pin pipecat-ai below 1.4, install plain bodhi-sdk (so pip doesn't
touch your pin) and import the same module, or copy
bodhi/integrations/pipecat_stt.py into your project — it is self-contained and
imports nothing else from this SDK.
Advanced features
Every field from the streaming advanced features page is reachable from here:
| Bodhi feature | How to set it |
|---|---|
| Context biasing (hotwords) | Settings(hotwords=[BodhiHotword("phrase", 2.0)]) |
| Endpoint silence threshold | Settings(endpoint_silence_duration=0.6) — seconds, clamped server-side to 0.44–1.2 |
| Parse numbers into numerals | Settings(parse_number=True) |
| Partial result exclusion | BodhiSTTService(..., interim_results=False) — also stops the server sending them |
| Aux metadata | BodhiSTTService(..., aux=True) |
| Confidence and word timings | already on every frame's result |
| Confidence filtering | BodhiSTTService(..., min_confidence=0.5) — Pipecat's guidance; 0 keeps everything |
result carries the raw Bodhi message, so word timings and confidence are
there on every final without setting any flag:
segment = frame.result["segment_meta"]
segment["confidence"] # 0.87 — utterance level
segment["words"][0] # {"word": "आपने", "confidence": 0.873,
# "start_time": 0.32, "end_time": 0.48}
aux=True adds an aux_info block on top of that, with request_time,
eot_wait_time and processed_audio_duration for latency debugging.
Trying it out
Two runnable examples, neither needing an LLM or TTS key:
export BODHI_API_KEY=... BODHI_CUSTOMER_ID=...
# 1. Transcribe a recording through a real Pipecat pipeline.
python examples/pipecat_stream_wav.py examples/loan.wav --model hi-banking-v2-8khz
# 2. Transcribe your microphone live in the browser.
pip install "pipecat-ai[webrtc,silero,runner]"
python examples/pipecat_mic_bot.py # then open http://localhost:7860/client
For a full talking bot, follow the
Pipecat quickstart and
replace its DeepgramSTTService(...) line with the BodhiSTTService(...) above.
docs/pipecat-listing/bodhi.mdx is this integration's service page for
docs.pipecat.ai, submitted as a
community integration.
Keep it in step with the parameters above.
For complete code examples and detailed usage instructions for various scenarios, please refer to the official documentation.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bodhi_sdk-1.3.0.tar.gz.
File metadata
- Download URL: bodhi_sdk-1.3.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f656944fa0d42c4d0e9b394e63cb03e921ce007406d123c0323b73c54afc8c
|
|
| MD5 |
5e2d3c1f7c99e6f8eaff23f06ba3487f
|
|
| BLAKE2b-256 |
b0fa7b5a4bc4a25b55058f9bd9a94e27492047c0e6d9f88ed4ad3ee816ca7baa
|
File details
Details for the file bodhi_sdk-1.3.0-py3-none-any.whl.
File metadata
- Download URL: bodhi_sdk-1.3.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fc6fff5ebd3216c3fd1926772205b219a07d86d5c96d2b170db5afd7f60e639
|
|
| MD5 |
fc26b6f46fb153700464bf6622c8d684
|
|
| BLAKE2b-256 |
897675997ecb8ab769f29a65c13327aa2c6c434dc1bf98ac5095bb5a5cfece10
|