> For the complete documentation index, see [llms.txt](https://navana.gitbook.io/bodhi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://navana.gitbook.io/bodhi/quickstart/streaming-websocket/advanced-features.md).

# Advanced Features

Refer to the features below for improving accuracy, increasing background noise resilience and more.

### :mag: Context Biasing (Hotwords)

You can boost recognition of important or uncommon phrases by specifying hotwords during the WebSocket request.

#### Using Hotwords

Define your hotwords as a JSON array. You can specifiy a higher "boosting score" if you would like to provide extra emphasis to longer phrases (recommended!). Currently, the default score applied is `1.5` which should be sufficient for single words.

<pre class="language-python"><code class="lang-python"><strong>hindi_hotwords = [
</strong>  { "phrase": "बोधी" },
  { "phrase": "स्पीच रिकग्निशन", "score": 2.5 }
]
</code></pre>

Once you have defined your JSON array of hotwords, you can input it to the model while sending in the configuration

```python
await ws.send(
    json.dumps(
        {
            "config": {
                "sample_rate": 8000,
                "transaction_id": str(uuid.uuid4()),
                "model": "hi-banking-v2-8khz",
                "hotwords": hindi_hotwords
            }
        }
    )
)
```

#### Best Practices

| Best Practice                          | Description                                                                                                           |
| -------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| ✅ Use uncommon words                   | Target domain-specific or rare phrases like `"`बोधी स्पीच रिकग्निशन`"`                                                |
| ✅ Use local script                     | Always write in Devanagari (e.g. बोधी, not `bodhi`)                                                                   |
| ✅ Avoid punctuation                    | Remove quotes, commas, periods                                                                                        |
| ✅ Use higher scores for longer phrases | <p>e.g. <code>"</code>बोधी स्पीच रिकग्निशन <code>" -> 2.5</code> vs</p><p><code>"</code>बोधी<code>" -> 1.5</code></p> |

> Avoid copying hotwords from other providers without validation. Bodhi may already support commonly spoken Hindi words natively.

#### Warnings

* Avoid very short particles like `"का"`, `"की"`, `"ए"`, etc.
* Don’t boost every word in a sentence — only uncommon or error-prone segments.
* Phrases work better for commonly missed phrases, individual tokens are better for rare words.
* Avoid boosting words that already work as is.

***

### 🧠 Confidence Scoring

Bodhi returns both **segment-level** confidence for all finalized results. You can use this to decide whether to use the response or not. For instance, in extremely noisy surrounding, confidence thresholds can be used to reduce unintended transcriptions.

#### Segment Confidence

```json
{
  "text": "मुझे जानकारी चाहिए",
  "is_final": true,
  "confidence": 0.79
}
```

#### Word-level Confidence

```json
{
  "text": "मुझे जानकारी चाहिए",
  "is_final": true,
  "confidence": 0.79,
  "words": [
    { "word": "मुझे", "confidence": 0.82 },
    { "word": "जानकारी", "confidence": 0.91 },
    { "word": "चाहिए", "confidence": 0.72 }
  ]
}
```

#### Recommended Usage

| Use Case                           | Strategy                                                                                                 |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Filter out weak segments           | Depending on language the confidence threshold can be somewhere in the range of 0.65 - 0.75.             |
| Tune per language and per use case | Call center vs dictation use cases need different thresholds. This threshold can also vary per language. |

***

### 🧹 Partial Result Exclusion

To avoid reacting to incomplete guesses, use the `exclude_partial` flag in the configuration. The client will only receive complete transcripts.

```json
{
    "config": {
        "sample_rate": sample_rate,
        "transaction_id": str(uuid.uuid4()),
        "model": "hi-banking-v2-8khz",
        "exclude_partial":True
    }
}
```

***

### ⏱️ Configurable Endpoint Silence Threshold

In streaming recognition, the ASR engine has to decide when a speaker has finished an utterance so it can emit a **final** transcript — the cue for a voice agent to respond. This decision is called **endpointing**.

The **endpoint silence threshold** is the trailing silence duration after which the recognizer finalizes an utterance, and it can be set per request with `endpoint_silence_duration`. A lower value finalizes faster (lower latency) but can split a sentence on a natural pause; a higher value tolerates pauses but adds delay.

Use it whenever the default endpointing cuts callers off early or waits too long after they have stopped speaking — voice bots, IVR, live captioning and agent-assist.

#### ⚙️ How It Works

When the speaker stops, a silence timer starts. If the silence lasts for the configured threshold, the recognizer closes the utterance and emits a final transcript.

#### ✅ How to Enable

In your config:

```json
{
    "config": {
        "sample_rate": sample_rate,
        "transaction_id": str(uuid.uuid4()),
        "model": "hi-banking-v2-8khz",
        "parse_number": true,
        "endpoint_silence_duration": 0.5
    }
}
```

***

#### 📏 Parameter Details

| Property        | Value                                                          |
| --------------- | -------------------------------------------------------------- |
| Unit            | Seconds                                                        |
| Default         | `0.44` — applied when the parameter is not provided            |
| Minimum         | `0.44` — any lower value is automatically clamped up to `0.44` |
| Maximum         | `1.2` — any higher value is automatically capped at `1.2`      |
| Effective range | `0.44` to `1.2` seconds                                        |

***

#### 🎚️ How to Tune It

Start at the default of `0.44` seconds and adjust based on what you observe in real conversations.

If the voice agent is interrupting callers — jumping in while they are still speaking, or breaking a single sentence into multiple finals — the threshold is too low. Increase it in small steps (for example `0.45`, `0.5`, `0.55`) until speakers can finish naturally without being cut off.

> Raise the threshold only as far as needed. Find the lowest value at which agent cut-offs are minimized without noticeably affecting latency.

***

### 🔢 Parse Numbers into Numerals

Bodhi supports converting spoken number words into actual digits using the `parse_number` flag in the WebSocket config.

This is useful when transcribing sentences that include monetary values, phone numbers, addresses, or quantities — especially for use cases like banking, insurance, and logistics.

#### ✅ How to Enable

In your config:

```json
{
    "config": {
        "sample_rate": sample_rate,
        "transaction_id": str(uuid.uuid4()),
        "model": "hi-banking-v2-8khz",
        "parse_number":True
    }
}
```

***

#### 🧾 Example

| Mode                          | Output                                           |
| ----------------------------- | ------------------------------------------------ |
| **Without `parse_number`**    | `"घर बनाने के लिए मुझे पच्चीस लाख का लोन चाहिए"` |
| **With `parse_number: True`** | `"घर बनाने के लिए मुझे 2500000 का लोन चाहिए"`    |

***

#### 🌐 Language Support

This feature is currently available for:

* Hindi (`hi`)
* Malayalam (`ml`)
* Kannada (`kn`)
* Gujarati (`gu`)
* Marathi (`mr`)

> Want support for another language? Reach out to <support@navanatech.in>

***

### 📦 Aux Metadata

Set `aux: true` in your config to receive **server-side diagnostic metadata** along with your transcript response.

This is useful for logging, benchmarking, or correlating timestamps across systems.

#### ✅ How to Enable

```json
{
  "aux": true
}
```

***

#### 📘 What You Get

When enabled, each final transcript message will include an `aux_info` block:

```json
"aux_info": {
  "request_time": 0.172,
  "received_request_time": "2025-05-19T09:32:11.459Z"
}
```

| Field                   | Description                                                                                            |
| ----------------------- | ------------------------------------------------------------------------------------------------------ |
| `request_time`          | Total time in seconds that the server spent handling this request (excluding network transfer delays). |
| `received_request_time` | The timestamp (UTC) when the server received the initial WebSocket connection or request.              |

This can help you:

* Profile server-side performance
* Track session start times
* Debug slow or idle sessions

***
