> ## Documentation Index
> Fetch the complete documentation index at: https://daily-hush-pcc-session-recordings-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gnani

> Speech-to-text services for Gnani Vachana — REST and WebSocket streaming for Indian languages

export const CommunityMaintained = ({maintainer, maintainerUrl, repo}) => <Note>
    <strong>Community-maintained integration.</strong> This service is built and
    maintained by{" "}
    <a href={maintainerUrl} target="_blank" rel="noreferrer">
      {maintainer}
    </a>
    . Pipecat does not test or officially support it. Please report issues and
    request changes on the{" "}
    <a href={repo} target="_blank" rel="noreferrer">
      source repository
    </a>
    . Learn more about{" "}
    <a href="/api-reference/server/services/community-integrations">
      community integrations
    </a>
    .
  </Note>;

<CommunityMaintained maintainer="Gnani-AI-Mintlify" maintainerUrl="https://github.com/Gnani-AI-Mintlify" repo="https://github.com/Gnani-AI-Mintlify/pipecat-gnani" />

## Overview

`GnaniHttpSTTService` and `GnaniSTTService` transcribe speech using
[Gnani Vachana](https://gnani.ai/), a production speech AI platform for 10+
Indian languages with real-time streaming and multilingual transcription.

Use `GnaniHttpSTTService` for REST-based file transcription of VAD-segmented
utterances, or `GnaniSTTService` for low-latency WebSocket streaming with
built-in VAD events. The WebSocket service emits `TranscriptionFrame` (final)
and `InterimTranscriptionFrame` when the API sets `is_final: false`.

<CardGroup cols={2}>
  <Card title="Source Repository" icon="github" href="https://github.com/Gnani-AI-Mintlify/pipecat-gnani">
    Source code, examples, and issues for the Gnani integration
  </Card>

  <Card title="PyPI Package" icon="cube" href="https://pypi.org/project/pipecat-gnani/">
    The `pipecat-gnani` package on PyPI
  </Card>

  <Card title="Gnani Website" icon="globe" href="https://gnani.ai">
    Learn about Gnani's speech AI platform
  </Card>

  <Card title="Gnani API Docs" icon="book" href="https://docs.gnani.ai/">
    STT REST and WebSocket API reference
  </Card>

  <Card title="Demo Video" icon="play" href="https://go.screenpal.com/watch/cOi2nynUax5">
    Gnani × Pipecat integration — STT/TTS pipeline and interruption handling
  </Card>

  <Card title="gnani-vachana SDK" icon="cube" href="https://pypi.org/project/gnani-vachana/">
    Core Gnani Vachana Python SDK (>= 0.7.9) installed as a dependency
  </Card>
</CardGroup>

## Installation

Install the community package directly:

```bash theme={null}
uv add pipecat-gnani
```

This also installs the [`gnani-vachana`](https://pypi.org/project/gnani-vachana/)
(>= 0.7.9) core SDK. The Python import package name remains `gnani`.

## Prerequisites

### Gnani Account Setup

Before using the Gnani STT services, you need:

1. **Gnani API key**: Get one from [Gnani APIs](https://app.gnani.ai/voice).
2. **Set credentials**: Export `GNANI_API_KEY` as an environment variable.

### Required Environment Variables

* `GNANI_API_KEY`: Your Gnani Vachana API key for authentication

## Configuration

### `GnaniHttpSTTService` (REST)

<ParamField path="api_key" type="str" required>
  Gnani Vachana API key for authentication.
</ParamField>

<ParamField path="aiohttp_session" type="aiohttp.ClientSession" required>
  Shared aiohttp session for HTTP requests.
</ParamField>

<ParamField path="settings" type="GnaniHttpSTTService.Settings" default="None">
  Runtime-updatable STT settings. See [Settings](#settings) below.
</ParamField>

<Note>
  `GnaniHttpSTTService` extends `SegmentedSTTService` and requires VAD in the
  pipeline so that speech segments are buffered and sent as whole utterances.
</Note>

### `GnaniSTTService` (WebSocket)

<ParamField path="api_key" type="str" required>
  Gnani Vachana API key for authentication.
</ParamField>

<ParamField path="sample_rate" type="int" default="None">
  Audio sample rate in Hz. One of `8000`, `16000`, `44100`, or `48000`. When
  omitted, the rate is negotiated from `StartFrame`.
</ParamField>

<ParamField path="keepalive_timeout" type="float" default="None">
  Seconds of silence before sending keepalive audio. `None` disables keepalive.
</ParamField>

<ParamField path="keepalive_interval" type="float" default="5.0">
  Seconds between keepalive checks when keepalive is enabled.
</ParamField>

<ParamField path="settings" type="GnaniSTTService.Settings" default="None">
  Runtime-updatable STT settings. See [Settings](#settings) below.
</ParamField>

### Settings

Runtime-configurable settings passed via the `settings` constructor argument.

**`GnaniHttpSTTService.Settings`**

| Parameter             | Type       | Default          | Description                                                        |
| --------------------- | ---------- | ---------------- | ------------------------------------------------------------------ |
| `language`            | `Language` | `Language.EN_IN` | Recognition language (BCP-47, e.g. `Language.HI_IN`).              |
| `format`              | `str`      | `None`           | `verbatim` for raw output, `transcribe` for ITN-normalized output. |
| `itn_native_numerals` | `bool`     | `None`           | When `format=transcribe`, render digits in native script.          |

**`GnaniSTTService.Settings`**

| Parameter             | Type       | Default          | Description                                                        |
| --------------------- | ---------- | ---------------- | ------------------------------------------------------------------ |
| `language`            | `Language` | `Language.EN_IN` | Recognition language (BCP-47, e.g. `Language.HI_IN`).              |
| `sample_rate`         | `int`      | `None`           | Audio sample rate (`8000`, `16000`, `44100`, or `48000`).          |
| `format`              | `str`      | `None`           | `verbatim` for raw output, `transcribe` for ITN-normalized output. |
| `itn_native_numerals` | `bool`     | `None`           | When `format=transcribe`, render digits in native script.          |

<Note>
  Supported STT languages include Assamese, Bengali, English (India), Gujarati,
  Hindi, Kannada, Malayalam, Marathi, Odia, Punjabi, Tamil, and Telugu. Changing
  `language`, `format`, `itn_native_numerals`, or `sample_rate` mid-session on
  the WebSocket service reconnects to re-run the init handshake. See the [source
  repository](https://github.com/Gnani-AI-Mintlify/pipecat-gnani) for the
  authoritative, up-to-date list.
</Note>

### Streaming PCM specification

WebSocket STT sends **raw PCM binary frames** — no WAV or MP3 container
mid-stream. Each frame is **1,024 bytes** (512 samples × 2 bytes, 16-bit
little-endian mono). Send frames at **real-time cadence** for best VAD accuracy.

| Property        | 16 kHz                          | 8 kHz                           |
| --------------- | ------------------------------- | ------------------------------- |
| Encoding        | PCM signed 16-bit little-endian | PCM signed 16-bit little-endian |
| Sample rate     | 16,000 Hz                       | 8,000 Hz                        |
| Channels        | 1 (mono)                        | 1 (mono)                        |
| Bytes per frame | 1,024                           | 1,024                           |
| Frame duration  | 32 ms                           | 64 ms                           |

`GnaniSTTService` also accepts **44,100 Hz** and **48,000 Hz** sample rates
(`x-sample-rate` header). The server resamples internally — still send 1,024-byte
frames at the appropriate cadence. See [STT Realtime — PCM
Specification](https://docs.gnani.ai/api/STT/stt-websocket#pcm-specification).

## Usage

### Streaming (WebSocket)

```python theme={null}
import os

from pipecat_gnani import GnaniSTTService

stt = GnaniSTTService(
    api_key=os.getenv("GNANI_API_KEY"),
    sample_rate=16000,
    settings=GnaniSTTService.Settings(
        language=Language.HI_IN,
    ),
)

# ... add stt to your pipeline
```

### REST (file-based)

```python theme={null}
import os

from pipecat_gnani import GnaniHttpSTTService

stt = GnaniHttpSTTService(
    api_key=os.getenv("GNANI_API_KEY"),
    aiohttp_session=session,
    settings=GnaniHttpSTTService.Settings(
        language=Language.HI_IN,
    ),
)

# ... add stt to your pipeline (VAD required)
```

## Compatibility

Tested with the latest **Pipecat** main branch (**v1.5.0+**) using `pipecat-gnani`. Requires **`gnani-vachana` >= 0.7.9**. Check the [source repository](https://github.com/Gnani-AI-Mintlify/pipecat-gnani) for the latest tested version and changelog.
