Skip to main content

Bodhi Python SDK for Streaming Speech Recognition

Project description

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",
      )
      response = client.transcribe_local_file(audio_file_path, config=config)
      print(response.text)
      
    • Remote URL Transcription:

      config = TranscriptionConfig(
        model="hi-banking-v2-8khz",
      )
      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.

For complete code examples and detailed usage instructions for various scenarios, please refer to the official documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bodhi_sdk-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bodhi_sdk-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file bodhi_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: bodhi_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for bodhi_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2ce23505be6fdd46c10391abe170a82d1e8687307ad218196fc4e6c5501e3cc2
MD5 ba73074442e72d1de089a92e96d0b32d
BLAKE2b-256 02a9bd0bc8a2866eb2861eba98a536a74d90649ae4a64f63aafa2d08bdb63244

See more details on using hashes here.

File details

Details for the file bodhi_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bodhi_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for bodhi_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10f1b8cf860d000b5e908d5d3839caaa1f3bb86e4e05f199e0d58486a9800c1f
MD5 41f36b05dd94c895bd333ca0b25e38db
BLAKE2b-256 92ddd8c9bf14b1891aca6832bfefc5fa1ec4417a7e99cac8327dceea1b41cfd6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page