> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sarvamai

> JavaScript API reference for the sarvamai speech-to-text plugin.

## SarvamAISTT

Sarvam AI speech-to-text (STT) transcriber.

### Constructor

```typescript theme={null}
new SarvamAISTT(opts: SarvamAISTTOptions)
```

<ParamField path="apiKey" type="string">
  Sarvam AI API key. Defaults to the `SARVAM_API_KEY` environment variable.
</ParamField>

<ParamField path="model" type="SarvamAISTTModel | string">
  Transcription model id. Default `'saaras:v3'`.
</ParamField>

<ParamField path="language" type="string">
  Spoken language code. Default `'en-IN'`.
</ParamField>

<ParamField path="inputSampleRate" type="number">
  Sample rate (Hz) of the audio sent in. Default `48000`.
</ParamField>

<ParamField path="outputSampleRate" type="number">
  Sample rate in Hz that input audio is resampled to. Default `16000`.
</ParamField>

<ParamField path="mode" type="string | null">
  Decoding mode. Default `null` (provider default).
</ParamField>

<ParamField path="highVadSensitivity" type="boolean | null">
  Use a more sensitive VAD profile. Default `null`.
</ParamField>

<ParamField path="flushSignals" type="boolean | null">
  Emit flush signals between turns. Default `null`.
</ParamField>

<ParamField path="translation" type="boolean">
  Translate transcripts to the target language. Default `false`.
</ParamField>

<ParamField path="prompt" type="string | null">
  Optional prompt to bias transcription. Default `null`.
</ParamField>

<ParamField path="inputAudioCodec" type="string">
  Input audio codec. Default `'pcm_s16le'`.
</ParamField>

<ParamField path="vadSignals" type="boolean | null">
  Emit VAD signals. Default `true`.
</ParamField>

<ParamField path="positiveSpeechThreshold" type="number | null">
  VAD probability above which a frame counts as speech. Default `null`.
</ParamField>

<ParamField path="negativeSpeechThreshold" type="number | null">
  VAD probability below which a frame counts as non-speech. Default `null`.
</ParamField>

<ParamField path="minSpeechFrames" type="number | null">
  Minimum frames of speech to start a turn. Default `null`.
</ParamField>

<ParamField path="firstTurnMinSpeechFrames" type="number | null">
  Minimum speech frames for the first turn. Default `null`.
</ParamField>

<ParamField path="preSpeechPadFrames" type="number | null">
  Audio frames of padding prepended before speech. Default `null`.
</ParamField>

<ParamField path="interruptMinSpeechFrames" type="number | null">
  Minimum speech frames required to interrupt. Default `null`.
</ParamField>

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds
for in-flight async handlers to settle before returning.

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onSttTranscript

```typescript theme={null}
onSttTranscript(callback: SttTranscriptCallback): void
```

Register a callback to receive transcripts as they are produced.

<ParamField path="callback" type="SttTranscriptCallback" required />

### processAudio

```typescript theme={null}
processAudio(_audioFrames: Uint8Array, _language?: string | null, ..._extra: any[]): Promise<void>
```

Process a buffer of audio frames. Override in a custom provider.

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### streamTranscribe

```typescript theme={null}
streamTranscribe(_audioStream: AsyncIterable<Uint8Array>, ..._extra: any[]): AsyncIterator<STTResponse>
```

Transcribe a streaming audio source, yielding STTResponses. Override in a custom provider.

<ResponseField name="returns" type="AsyncIterator<STTResponse>" />

***

## SarvamAISTTModel

Supported Sarvam AI STT model names.

### Fields

<ParamField path="toString" type="string" required>
  Returns a string representation of a string.
</ParamField>

<ParamField path="charAt" type="string" required>
  Returns the character at the specified index.
</ParamField>

<ParamField path="charCodeAt" type="number" required>
  Returns the Unicode value of the character at the specified location.
</ParamField>

<ParamField path="concat" type="string" required>
  Returns a string that contains the concatenation of two or more strings.
</ParamField>

<ParamField path="indexOf" type="number" required>
  Returns the position of the first occurrence of a substring.
</ParamField>

<ParamField path="lastIndexOf" type="number" required>
  Returns the last occurrence of a substring in the string.
</ParamField>

<ParamField path="localeCompare" type="number" required>
  Determines whether two strings are equivalent in the current locale.
</ParamField>

<ParamField path="match" type="RegExpMatchArray | null" required>
  Matches a string with a regular expression, and returns an array containing the results of that search.
</ParamField>

<ParamField path="replace" type="string" required>
  Replaces text in a string, using a regular expression or search string.
</ParamField>

<ParamField path="search" type="number" required>
  Finds the first substring match in a regular expression search.
</ParamField>

<ParamField path="slice" type="string" required>
  Returns a section of a string.
</ParamField>

<ParamField path="split" type="string[]" required>
  Split a string into substrings using the specified separator and return them as an array.
</ParamField>

<ParamField path="substring" type="string" required>
  Returns the substring at the specified location within a String object.
</ParamField>

<ParamField path="toLowerCase" type="string" required>
  Converts all the alphabetic characters in a string to lowercase.
</ParamField>

<ParamField path="toLocaleLowerCase" type="string" required>
  Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.
</ParamField>

<ParamField path="toUpperCase" type="string" required>
  Converts all the alphabetic characters in a string to uppercase.
</ParamField>

<ParamField path="toLocaleUpperCase" type="string" required>
  Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale.
</ParamField>

<ParamField path="trim" type="string" required>
  Removes the leading and trailing white space and line terminator characters from a string.
</ParamField>

<ParamField path="length" type="number" required>
  Returns the length of a String object.
</ParamField>

<ParamField path="substr" type="string" required>
  Gets a substring beginning at the specified location and having the specified length.
</ParamField>

<ParamField path="valueOf" type="string" required>
  Returns the primitive value of the specified object.
</ParamField>

<ParamField path="codePointAt" type="number | undefined" required>
  Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
  value of the UTF-16 encoded code point starting at the string element at position pos in
  the String resulting from converting this object to a String.
  If there is no element at that position, the result is undefined.
  If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
</ParamField>

<ParamField path="includes" type="boolean" required>
  Returns true if searchString appears as a substring of the result of converting this
  object to a String, at one or more positions that are
  greater than or equal to position; otherwise, returns false.
</ParamField>

<ParamField path="endsWith" type="boolean" required>
  Returns true if the sequence of elements of searchString converted to a String is the
  same as the corresponding elements of this object (converted to a String) starting at
  endPosition – length(this). Otherwise returns false.
</ParamField>

<ParamField path="normalize" type="string" required>
  Returns the String value result of normalizing the string into the normalization form
  named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
</ParamField>

<ParamField path="repeat" type="string" required>
  Returns a String value that is made from count copies appended together. If count is 0,
  the empty string is returned.
</ParamField>

<ParamField path="startsWith" type="boolean" required>
  Returns true if the sequence of elements of searchString converted to a String is the
  same as the corresponding elements of this object (converted to a String) starting at
  position. Otherwise returns false.
</ParamField>

<ParamField path="anchor" type="string" required>
  Returns an `<a>` HTML anchor element and sets the name attribute to the text value
</ParamField>

<ParamField path="big" type="string" required>
  Returns a `<big>` HTML element
</ParamField>

<ParamField path="blink" type="string" required>
  Returns a `<blink>` HTML element
</ParamField>

<ParamField path="bold" type="string" required>
  Returns a `<b>` HTML element
</ParamField>

<ParamField path="fixed" type="string" required>
  Returns a `<tt>` HTML element
</ParamField>

<ParamField path="fontcolor" type="string" required>
  Returns a `<font>` HTML element and sets the color attribute value
</ParamField>

<ParamField path="fontsize" type="string" required>
  Returns a `<font>` HTML element and sets the size attribute value
</ParamField>

<ParamField path="italics" type="string" required>
  Returns an `<i>` HTML element
</ParamField>

<ParamField path="link" type="string" required>
  Returns an `<a>` HTML element and sets the href attribute value
</ParamField>

<ParamField path="small" type="string" required>
  Returns a `<small>` HTML element
</ParamField>

<ParamField path="strike" type="string" required>
  Returns a `<strike>` HTML element
</ParamField>

<ParamField path="sub" type="string" required>
  Returns a `<sub>` HTML element
</ParamField>

<ParamField path="sup" type="string" required>
  Returns a `<sup>` HTML element
</ParamField>

<ParamField path="padStart" type="string" required>
  Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
  The padding is applied from the start (left) of the current string.
</ParamField>

<ParamField path="padEnd" type="string" required>
  Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
  The padding is applied from the end (right) of the current string.
</ParamField>

<ParamField path="trimEnd" type="string" required>
  Removes the trailing white space and line terminator characters from a string.
</ParamField>

<ParamField path="trimStart" type="string" required>
  Removes the leading white space and line terminator characters from a string.
</ParamField>

<ParamField path="trimLeft" type="string" required>
  Removes the leading white space and line terminator characters from a string.
</ParamField>

<ParamField path="trimRight" type="string" required>
  Removes the trailing white space and line terminator characters from a string.
</ParamField>

<ParamField path="matchAll" type="RegExpStringIterator<RegExpExecArray>" required>
  Matches a string with a regular expression, and returns an iterable of matches
  containing the results of that search.
</ParamField>

<ParamField path="replaceAll" type="string" required>
  Replace all instances of a substring in a string, using a regular expression or search string.
</ParamField>

<ParamField path="at" type="string | undefined" required>
  Returns a new String consisting of the single UTF-16 code unit located at the specified index.
</ParamField>
