Skip to main content

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:

  1. Installation: Install the SDK using pip:

    pip install bodhi-sdk
    
  2. Initialization: Create a BodhiClient instance with your API key and customer ID:

    from bodhi import BodhiClient
    
    client = BodhiClient(api_key="YOUR_API_KEY", customer_id="YOUR_CUSTOMER_ID")
    
  3. 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)
        endpoint_silence_duration=0.6,  # Trailing silence before an utterance
                                        # is finalised, in seconds. Omitted
                                        # unless set; server default 0.44,
                                        # clamped to 0.44-1.2
      )
      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)
        endpoint_silence_duration=0.6,  # Trailing silence before an utterance
                                        # is finalised, in seconds. Omitted
                                        # unless set; server default 0.44,
                                        # clamped to 0.44-1.2
      )
      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.

  4. Event Handling: You can register event listeners to handle different stages of the transcription process using the client.on method and the LiveTranscriptionEvents enum. 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; server default 0.44, clamped 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.

Metadata

Release files for bodhi-sdk 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bodhi-sdk 1.4.0
File Size Uploaded Provenance Actions
bodhi_sdk-1.4.0.tar.gz 27.2 kB Without provenance Details for bodhi_sdk-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bodhi-sdk 1.4.0
File Interpreter ABI Platform Actions
bodhi_sdk-1.4.0-py3-none-any.whl Python 3 none any Details for bodhi_sdk-1.4.0-py3-none-any.whl

Total release size: 57.5 kB

Release files / bodhi_sdk-1.4.0.tar.gz

Download URL bodhi_sdk-1.4.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c2de736035cfa1e8e082f8687025a6d5ea8ae3495a26a893e742465ef8e28368
BLAKE2b-256 checksum
How to use checksums
9f90abcf54386bfa75fb2614524232229f3f08a76c981791698ae7e3152828f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / bodhi_sdk-1.4.0-py3-none-any.whl

Download URL bodhi_sdk-1.4.0-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e5988948bab66d0b48e14cd10ef66ccb51cf722fc8cef937f92f5983ff7154a
BLAKE2b-256 checksum
How to use checksums
1b6f2c054d8867dbe6ec9168ad5dffaa6f0592411c4d6b762594eb38adbb60b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for bodhi-sdk 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page