|
| 1 | +--- |
| 2 | +title: Rev.ai |
| 3 | +description: Learn how to use the Rev.ai provider for the AI SDK. |
| 4 | +--- |
| 5 | + |
| 6 | +# Rev.ai Provider |
| 7 | + |
| 8 | +The [Rev.ai](https://www.rev.ai/) provider contains language model support for the Rev.ai transcription API. |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +The Rev.ai provider is available in the `@ai-sdk/revai` module. You can install it with |
| 13 | + |
| 14 | +<Tabs items={['pnpm', 'npm', 'yarn']}> |
| 15 | + <Tab> |
| 16 | + <Snippet text="pnpm add @ai-sdk/revai" dark /> |
| 17 | + </Tab> |
| 18 | + <Tab> |
| 19 | + <Snippet text="npm install @ai-sdk/revai" dark /> |
| 20 | + </Tab> |
| 21 | + <Tab> |
| 22 | + <Snippet text="yarn add @ai-sdk/revai" dark /> |
| 23 | + </Tab> |
| 24 | +</Tabs> |
| 25 | + |
| 26 | +## Provider Instance |
| 27 | + |
| 28 | +You can import the default provider instance `revai` from `@ai-sdk/revai`: |
| 29 | + |
| 30 | +```ts |
| 31 | +import { revai } from '@ai-sdk/revai'; |
| 32 | +``` |
| 33 | + |
| 34 | +If you need a customized setup, you can import `createRevai` from `@ai-sdk/revai` and create a provider instance with your settings: |
| 35 | + |
| 36 | +```ts |
| 37 | +import { createRevai } from '@ai-sdk/revai'; |
| 38 | + |
| 39 | +const revai = createRevai({ |
| 40 | + // custom settings, e.g. |
| 41 | + fetch: customFetch, |
| 42 | +}); |
| 43 | +``` |
| 44 | + |
| 45 | +You can use the following optional settings to customize the Rev.ai provider instance: |
| 46 | + |
| 47 | +- **apiKey** _string_ |
| 48 | + |
| 49 | + API key that is being sent using the `Authorization` header. |
| 50 | + It defaults to the `REVAI_API_KEY` environment variable. |
| 51 | + |
| 52 | +- **headers** _Record<string,string>_ |
| 53 | + |
| 54 | + Custom headers to include in the requests. |
| 55 | + |
| 56 | +- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_ |
| 57 | + |
| 58 | + Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation. |
| 59 | + Defaults to the global `fetch` function. |
| 60 | + You can use it as a middleware to intercept requests, |
| 61 | + or to provide a custom fetch implementation for e.g. testing. |
| 62 | + |
| 63 | +## Transcription Models |
| 64 | + |
| 65 | +You can create models that call the [Rev.ai transcription API](https://www.rev.ai/docs/api/transcription) |
| 66 | +using the `.transcription()` factory method. |
| 67 | + |
| 68 | +The first argument is the model id e.g. `machine`. |
| 69 | + |
| 70 | +```ts |
| 71 | +const model = revai.transcription('machine'); |
| 72 | +``` |
| 73 | + |
| 74 | +You can also pass additional provider-specific options using the `providerOptions` argument. For example, supplying the input language in ISO-639-1 (e.g. `en`) format can sometimes improve transcription performance if known beforehand. |
| 75 | + |
| 76 | +```ts highlight="6" |
| 77 | +import { experimental_transcribe as transcribe } from 'ai'; |
| 78 | +import { revai } from '@ai-sdk/revai'; |
| 79 | +import { readFile } from 'fs/promises'; |
| 80 | + |
| 81 | +const result = await transcribe({ |
| 82 | + model: revai.transcription('machine'), |
| 83 | + audio: await readFile('audio.mp3'), |
| 84 | + providerOptions: { revai: { language: 'en' } }, |
| 85 | +}); |
| 86 | +``` |
| 87 | + |
| 88 | +The following provider options are available: |
| 89 | + |
| 90 | +- **metadata** _string_ |
| 91 | + |
| 92 | + Optional metadata that was provided during job submission. |
| 93 | + |
| 94 | +- **notification_config** _object_ |
| 95 | + |
| 96 | + Optional configuration for a callback url to invoke when processing is complete. |
| 97 | + |
| 98 | + - **url** _string_ - Callback url to invoke when processing is complete. |
| 99 | + - **auth_headers** _object_ - Optional authorization headers, if needed to invoke the callback. |
| 100 | + |
| 101 | +- **delete_after_seconds** _integer_ |
| 102 | + |
| 103 | + Amount of time after job completion when job is auto-deleted. |
| 104 | + |
| 105 | +- **verbatim** _boolean_ |
| 106 | + |
| 107 | + Configures the transcriber to transcribe every syllable, including all false starts and disfluencies. |
| 108 | + |
| 109 | +- **rush** _boolean_ |
| 110 | + |
| 111 | + [HIPAA Unsupported] Only available for human transcriber option. When set to true, your job is given higher priority. |
| 112 | + |
| 113 | +- **skip_diarization** _boolean_ |
| 114 | + |
| 115 | + Specify if speaker diarization will be skipped by the speech engine. |
| 116 | + |
| 117 | +- **skip_postprocessing** _boolean_ |
| 118 | + |
| 119 | + Only available for English and Spanish languages. User-supplied preference on whether to skip post-processing operations. |
| 120 | + |
| 121 | +- **skip_punctuation** _boolean_ |
| 122 | + |
| 123 | + Specify if "punct" type elements will be skipped by the speech engine. |
| 124 | + |
| 125 | +- **remove_disfluencies** _boolean_ |
| 126 | + |
| 127 | + When set to true, disfluencies (like 'ums' and 'uhs') will not appear in the transcript. |
| 128 | + |
| 129 | +- **remove_atmospherics** _boolean_ |
| 130 | + |
| 131 | + When set to true, atmospherics (like `<laugh>`, `<affirmative>`) will not appear in the transcript. |
| 132 | + |
| 133 | +- **filter_profanity** _boolean_ |
| 134 | + |
| 135 | + When enabled, profanities will be filtered by replacing characters with asterisks except for the first and last. |
| 136 | + |
| 137 | +- **speaker_channels_count** _integer_ |
| 138 | + |
| 139 | + Only available for English, Spanish and French languages. Specify the total number of unique speaker channels in the audio. |
| 140 | + |
| 141 | +- **speakers_count** _integer_ |
| 142 | + |
| 143 | + Only available for English, Spanish and French languages. Specify the total number of unique speakers in the audio. |
| 144 | + |
| 145 | +- **diarization_type** _string_ |
| 146 | + |
| 147 | + Specify diarization type. Possible values: "standard" (default), "premium". |
| 148 | + |
| 149 | +- **custom_vocabulary_id** _string_ |
| 150 | + |
| 151 | + Supply the id of a pre-completed custom vocabulary submitted through the Custom Vocabularies API. |
| 152 | + |
| 153 | +- **custom_vocabularies** _Array_ |
| 154 | + |
| 155 | + Specify a collection of custom vocabulary to be used for this job. |
| 156 | + |
| 157 | +- **strict_custom_vocabulary** _boolean_ |
| 158 | + |
| 159 | + If true, only exact phrases will be used as custom vocabulary. |
| 160 | + |
| 161 | +- **summarization_config** _object_ |
| 162 | + |
| 163 | + Specify summarization options. |
| 164 | + |
| 165 | + - **model** _string_ - Model type for summarization. Possible values: "standard" (default), "premium". |
| 166 | + - **type** _string_ - Summarization formatting type. Possible values: "paragraph" (default), "bullets". |
| 167 | + - **prompt** _string_ - Custom prompt for flexible summaries (mutually exclusive with type). |
| 168 | + |
| 169 | +- **translation_config** _object_ |
| 170 | + |
| 171 | + Specify translation options. |
| 172 | + |
| 173 | + - **target_languages** _Array_ - Array of target languages for translation. |
| 174 | + - **model** _string_ - Model type for translation. Possible values: "standard" (default), "premium". |
| 175 | + |
| 176 | +- **language** _string_ |
| 177 | + |
| 178 | + Language is provided as a ISO 639-1 language code. Default is "en". |
| 179 | + |
| 180 | +- **forced_alignment** _boolean_ |
| 181 | + |
| 182 | + When enabled, provides improved accuracy for per-word timestamps for a transcript. |
| 183 | + Default is `false`. |
| 184 | + |
| 185 | + Currently supported languages: |
| 186 | + |
| 187 | + - English (en, en-us, en-gb) |
| 188 | + - French (fr) |
| 189 | + - Italian (it) |
| 190 | + - German (de) |
| 191 | + - Spanish (es) |
| 192 | + |
| 193 | + Note: This option is not available in low-cost environment. |
| 194 | + |
| 195 | +### Model Capabilities |
| 196 | + |
| 197 | +| Model | Transcription | Duration | Segments | Language | |
| 198 | +| ---------- | ------------------- | ------------------- | ------------------- | ------------------- | |
| 199 | +| `machine` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | |
| 200 | +| `human` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | |
| 201 | +| `low_cost` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | |
| 202 | +| `fusion` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | |
0 commit comments