@ai-sdk/revai 0.0.0-64aae7dd-20260114144918 → 0.0.0-98261322-20260122142521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/160-revai.mdx +206 -0
- package/package.json +10 -5
- package/src/index.ts +3 -0
- package/src/revai-api-types.ts +274 -0
- package/src/revai-config.ts +9 -0
- package/src/revai-error.test.ts +34 -0
- package/src/revai-error.ts +16 -0
- package/src/revai-provider.ts +120 -0
- package/src/revai-transcription-model.test.ts +282 -0
- package/src/revai-transcription-model.ts +516 -0
- package/src/revai-transcription-options.ts +1 -0
- package/src/transcript-test.mp3 +0 -0
- package/src/version.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
# @ai-sdk/revai
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-98261322-20260122142521
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- 080559b: chore: add docs to package dist
|
|
8
|
+
|
|
9
|
+
## 2.0.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8dc54db: chore: add src folders to package bundle
|
|
14
|
+
|
|
15
|
+
## 2.0.8
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [5c090e7]
|
|
20
|
+
- @ai-sdk/provider@3.0.4
|
|
21
|
+
- @ai-sdk/provider-utils@4.0.8
|
|
22
|
+
|
|
23
|
+
## 2.0.7
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [46f46e4]
|
|
28
|
+
- @ai-sdk/provider-utils@4.0.7
|
|
29
|
+
|
|
30
|
+
## 2.0.6
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [1b11dcb]
|
|
35
|
+
- @ai-sdk/provider-utils@4.0.6
|
|
36
|
+
- @ai-sdk/provider@3.0.3
|
|
10
37
|
|
|
11
38
|
## 2.0.5
|
|
12
39
|
|
package/dist/index.js
CHANGED
|
@@ -455,7 +455,7 @@ var revaiTranscriptionResponseSchema = import_v42.z.object({
|
|
|
455
455
|
});
|
|
456
456
|
|
|
457
457
|
// src/version.ts
|
|
458
|
-
var VERSION = true ? "0.0.0-
|
|
458
|
+
var VERSION = true ? "0.0.0-98261322-20260122142521" : "0.0.0-test";
|
|
459
459
|
|
|
460
460
|
// src/revai-provider.ts
|
|
461
461
|
function createRevai(options = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -443,7 +443,7 @@ var revaiTranscriptionResponseSchema = z2.object({
|
|
|
443
443
|
});
|
|
444
444
|
|
|
445
445
|
// src/version.ts
|
|
446
|
-
var VERSION = true ? "0.0.0-
|
|
446
|
+
var VERSION = true ? "0.0.0-98261322-20260122142521" : "0.0.0-test";
|
|
447
447
|
|
|
448
448
|
// src/revai-provider.ts
|
|
449
449
|
function createRevai(options = {}) {
|
|
@@ -0,0 +1,206 @@
|
|
|
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', 'bun']}>
|
|
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
|
+
|
|
25
|
+
<Tab>
|
|
26
|
+
<Snippet text="bun add @ai-sdk/revai" dark />
|
|
27
|
+
</Tab>
|
|
28
|
+
</Tabs>
|
|
29
|
+
|
|
30
|
+
## Provider Instance
|
|
31
|
+
|
|
32
|
+
You can import the default provider instance `revai` from `@ai-sdk/revai`:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { revai } from '@ai-sdk/revai';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you need a customized setup, you can import `createRevai` from `@ai-sdk/revai` and create a provider instance with your settings:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createRevai } from '@ai-sdk/revai';
|
|
42
|
+
|
|
43
|
+
const revai = createRevai({
|
|
44
|
+
// custom settings, e.g.
|
|
45
|
+
fetch: customFetch,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You can use the following optional settings to customize the Rev.ai provider instance:
|
|
50
|
+
|
|
51
|
+
- **apiKey** _string_
|
|
52
|
+
|
|
53
|
+
API key that is being sent using the `Authorization` header.
|
|
54
|
+
It defaults to the `REVAI_API_KEY` environment variable.
|
|
55
|
+
|
|
56
|
+
- **headers** _Record<string,string>_
|
|
57
|
+
|
|
58
|
+
Custom headers to include in the requests.
|
|
59
|
+
|
|
60
|
+
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
61
|
+
|
|
62
|
+
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
|
|
63
|
+
Defaults to the global `fetch` function.
|
|
64
|
+
You can use it as a middleware to intercept requests,
|
|
65
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
66
|
+
|
|
67
|
+
## Transcription Models
|
|
68
|
+
|
|
69
|
+
You can create models that call the [Rev.ai transcription API](https://www.rev.ai/docs/api/transcription)
|
|
70
|
+
using the `.transcription()` factory method.
|
|
71
|
+
|
|
72
|
+
The first argument is the model id e.g. `machine`.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const model = revai.transcription('machine');
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
```ts highlight="6"
|
|
81
|
+
import { experimental_transcribe as transcribe } from 'ai';
|
|
82
|
+
import { revai } from '@ai-sdk/revai';
|
|
83
|
+
import { readFile } from 'fs/promises';
|
|
84
|
+
|
|
85
|
+
const result = await transcribe({
|
|
86
|
+
model: revai.transcription('machine'),
|
|
87
|
+
audio: await readFile('audio.mp3'),
|
|
88
|
+
providerOptions: { revai: { language: 'en' } },
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The following provider options are available:
|
|
93
|
+
|
|
94
|
+
- **metadata** _string_
|
|
95
|
+
|
|
96
|
+
Optional metadata that was provided during job submission.
|
|
97
|
+
|
|
98
|
+
- **notification_config** _object_
|
|
99
|
+
|
|
100
|
+
Optional configuration for a callback url to invoke when processing is complete.
|
|
101
|
+
|
|
102
|
+
- **url** _string_ - Callback url to invoke when processing is complete.
|
|
103
|
+
- **auth_headers** _object_ - Optional authorization headers, if needed to invoke the callback.
|
|
104
|
+
- **Authorization** _string_ - Authorization header value.
|
|
105
|
+
|
|
106
|
+
- **delete_after_seconds** _integer_
|
|
107
|
+
|
|
108
|
+
Amount of time after job completion when job is auto-deleted.
|
|
109
|
+
|
|
110
|
+
- **verbatim** _boolean_
|
|
111
|
+
|
|
112
|
+
Configures the transcriber to transcribe every syllable, including all false starts and disfluencies.
|
|
113
|
+
|
|
114
|
+
- **rush** _boolean_
|
|
115
|
+
|
|
116
|
+
[HIPAA Unsupported] Only available for human transcriber option. When set to true, your job is given higher priority.
|
|
117
|
+
|
|
118
|
+
- **skip_diarization** _boolean_
|
|
119
|
+
|
|
120
|
+
Specify if speaker diarization will be skipped by the speech engine.
|
|
121
|
+
|
|
122
|
+
- **skip_postprocessing** _boolean_
|
|
123
|
+
|
|
124
|
+
Only available for English and Spanish languages. User-supplied preference on whether to skip post-processing operations.
|
|
125
|
+
|
|
126
|
+
- **skip_punctuation** _boolean_
|
|
127
|
+
|
|
128
|
+
Specify if "punct" type elements will be skipped by the speech engine.
|
|
129
|
+
|
|
130
|
+
- **remove_disfluencies** _boolean_
|
|
131
|
+
|
|
132
|
+
When set to true, disfluencies (like 'ums' and 'uhs') will not appear in the transcript.
|
|
133
|
+
|
|
134
|
+
- **remove_atmospherics** _boolean_
|
|
135
|
+
|
|
136
|
+
When set to true, atmospherics (like `<laugh>`, `<affirmative>`) will not appear in the transcript.
|
|
137
|
+
|
|
138
|
+
- **filter_profanity** _boolean_
|
|
139
|
+
|
|
140
|
+
When enabled, profanities will be filtered by replacing characters with asterisks except for the first and last.
|
|
141
|
+
|
|
142
|
+
- **speaker_channels_count** _integer_
|
|
143
|
+
|
|
144
|
+
Only available for English, Spanish and French languages. Specify the total number of unique speaker channels in the audio.
|
|
145
|
+
|
|
146
|
+
- **speakers_count** _integer_
|
|
147
|
+
|
|
148
|
+
Only available for English, Spanish and French languages. Specify the total number of unique speakers in the audio.
|
|
149
|
+
|
|
150
|
+
- **diarization_type** _string_
|
|
151
|
+
|
|
152
|
+
Specify diarization type. Possible values: "standard" (default), "premium".
|
|
153
|
+
|
|
154
|
+
- **custom_vocabulary_id** _string_
|
|
155
|
+
|
|
156
|
+
Supply the id of a pre-completed custom vocabulary submitted through the Custom Vocabularies API.
|
|
157
|
+
|
|
158
|
+
- **custom_vocabularies** _Array_
|
|
159
|
+
|
|
160
|
+
Specify a collection of custom vocabulary to be used for this job.
|
|
161
|
+
|
|
162
|
+
- **strict_custom_vocabulary** _boolean_
|
|
163
|
+
|
|
164
|
+
If true, only exact phrases will be used as custom vocabulary.
|
|
165
|
+
|
|
166
|
+
- **summarization_config** _object_
|
|
167
|
+
|
|
168
|
+
Specify summarization options.
|
|
169
|
+
|
|
170
|
+
- **model** _string_ - Model type for summarization. Possible values: "standard" (default), "premium".
|
|
171
|
+
- **type** _string_ - Summarization formatting type. Possible values: "paragraph" (default), "bullets".
|
|
172
|
+
- **prompt** _string_ - Custom prompt for flexible summaries (mutually exclusive with type).
|
|
173
|
+
|
|
174
|
+
- **translation_config** _object_
|
|
175
|
+
|
|
176
|
+
Specify translation options.
|
|
177
|
+
|
|
178
|
+
- **target_languages** _Array_ - Array of target languages for translation.
|
|
179
|
+
- **model** _string_ - Model type for translation. Possible values: "standard" (default), "premium".
|
|
180
|
+
|
|
181
|
+
- **language** _string_
|
|
182
|
+
|
|
183
|
+
Language is provided as a ISO 639-1 language code. Default is "en".
|
|
184
|
+
|
|
185
|
+
- **forced_alignment** _boolean_
|
|
186
|
+
|
|
187
|
+
When enabled, provides improved accuracy for per-word timestamps for a transcript.
|
|
188
|
+
Default is `false`.
|
|
189
|
+
|
|
190
|
+
Currently supported languages:
|
|
191
|
+
|
|
192
|
+
- English (en, en-us, en-gb)
|
|
193
|
+
- French (fr)
|
|
194
|
+
- Italian (it)
|
|
195
|
+
- German (de)
|
|
196
|
+
- Spanish (es)
|
|
197
|
+
|
|
198
|
+
Note: This option is not available in low-cost environment.
|
|
199
|
+
|
|
200
|
+
### Model Capabilities
|
|
201
|
+
|
|
202
|
+
| Model | Transcription | Duration | Segments | Language |
|
|
203
|
+
| ---------- | ------------------- | ------------------- | ------------------- | ------------------- |
|
|
204
|
+
| `machine` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
205
|
+
| `low_cost` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
206
|
+
| `fusion` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/revai",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-98261322-20260122142521",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,9 +8,14 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
11
|
+
"docs/**/*",
|
|
12
|
+
"src",
|
|
11
13
|
"CHANGELOG.md",
|
|
12
14
|
"README.md"
|
|
13
15
|
],
|
|
16
|
+
"directories": {
|
|
17
|
+
"doc": "./docs"
|
|
18
|
+
},
|
|
14
19
|
"exports": {
|
|
15
20
|
"./package.json": "./package.json",
|
|
16
21
|
".": {
|
|
@@ -20,15 +25,15 @@
|
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"dependencies": {
|
|
23
|
-
"@ai-sdk/provider": "
|
|
24
|
-
"@ai-sdk/provider-utils": "
|
|
28
|
+
"@ai-sdk/provider": "3.0.4",
|
|
29
|
+
"@ai-sdk/provider-utils": "4.0.8"
|
|
25
30
|
},
|
|
26
31
|
"devDependencies": {
|
|
27
32
|
"@types/node": "20.17.24",
|
|
28
33
|
"tsup": "^8",
|
|
29
34
|
"typescript": "5.6.3",
|
|
30
35
|
"zod": "3.25.76",
|
|
31
|
-
"@ai-sdk/test-server": "1.0.
|
|
36
|
+
"@ai-sdk/test-server": "1.0.2",
|
|
32
37
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|
|
@@ -54,7 +59,7 @@
|
|
|
54
59
|
"scripts": {
|
|
55
60
|
"build": "tsup --tsconfig tsconfig.build.json",
|
|
56
61
|
"build:watch": "tsup --tsconfig tsconfig.build.json --watch",
|
|
57
|
-
"clean": "del-cli dist",
|
|
62
|
+
"clean": "del-cli dist docs",
|
|
58
63
|
"lint": "eslint \"./**/*.ts*\"",
|
|
59
64
|
"type-check": "tsc --noEmit",
|
|
60
65
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
export type RevaiTranscriptionAPITypes = {
|
|
2
|
+
/**
|
|
3
|
+
* Optional metadata that was provided during job submission.
|
|
4
|
+
*/
|
|
5
|
+
metadata?: string | null;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Optional configuration for a callback url to invoke when processing is complete,
|
|
9
|
+
* in addition to auth headers if they are needed to invoke the callback url.
|
|
10
|
+
* Cannot be set if callback_url is set. This option will not be visible in the submission response.
|
|
11
|
+
*/
|
|
12
|
+
notification_config?: {
|
|
13
|
+
/**
|
|
14
|
+
* Optional callback url to invoke when processing is complete
|
|
15
|
+
*/
|
|
16
|
+
url: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional authorization headers, if they are needed to invoke the callback.
|
|
19
|
+
* There are a few constraints: 1) the "Authorization" header is the only header that can be passed in,
|
|
20
|
+
* and 2) the header value must be of the form <scheme> <token>.
|
|
21
|
+
* For example: {"Authorization": "Bearer $BEARER_TOKEN"}
|
|
22
|
+
*/
|
|
23
|
+
auth_headers?: {
|
|
24
|
+
/**
|
|
25
|
+
* Authorization header
|
|
26
|
+
*/
|
|
27
|
+
Authorization: string;
|
|
28
|
+
} | null;
|
|
29
|
+
} | null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Amount of time after job completion when job is auto-deleted. Present only when preference set in job request.
|
|
33
|
+
*/
|
|
34
|
+
delete_after_seconds?: number | null;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Select which service you would like to transcribe this file with.
|
|
38
|
+
* - machine: the default and routes to our standard (Reverb) model.
|
|
39
|
+
* - low_cost: low-cost transcription which uses quantized ASR model (Reverb Turbo) with low-cost environment.
|
|
40
|
+
* - fusion: higher quality ASR that combines multiple models to achieve the best results. Typically has better support for rare words.
|
|
41
|
+
* @default "machine"
|
|
42
|
+
*/
|
|
43
|
+
transcriber?: 'machine' | 'low_cost' | 'fusion' | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Configures the transcriber to transcribe every syllable. This will include all false starts and disfluencies in the transcript.
|
|
47
|
+
*
|
|
48
|
+
* The behavior depends on the transcriber option:
|
|
49
|
+
* - machine: the default is true. To turn it off false should be explicitly provided
|
|
50
|
+
* - human: the default is false To turn it on true should be explicitly provided
|
|
51
|
+
*/
|
|
52
|
+
verbatim?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* [HIPAA Unsupported] Only available for human transcriber option
|
|
56
|
+
* When this field is set to true your job is given higher priority and will be worked on sooner by our human transcribers.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
rush?: boolean | null;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* [HIPAA Unsupported] Only available for human transcriber option
|
|
63
|
+
* When this field is set to true the behavior will mock a normal human transcription job except no transcription will happen.
|
|
64
|
+
* The primary use case is to test integrations without being charged for human transcription.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
test_mode?: boolean | null;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* [HIPAA Unsupported] Only available for human transcriber option.
|
|
71
|
+
* Use this option to specify which sections of the transcript need to be transcribed.
|
|
72
|
+
* Segments must be at least 1 minute in length and cannot overlap.
|
|
73
|
+
*/
|
|
74
|
+
segments_to_transcribe?: Array<{
|
|
75
|
+
/**
|
|
76
|
+
* The timestamp of the beginning of the segment relative to the beginning of the audio in seconds (centisecond precision)
|
|
77
|
+
*/
|
|
78
|
+
start: number;
|
|
79
|
+
/**
|
|
80
|
+
* The timestamp of the end of the segment relative to the beginning of the audio in seconds (centisecond precision)
|
|
81
|
+
*/
|
|
82
|
+
end: number;
|
|
83
|
+
}> | null;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* [HIPAA Unsupported] Only available for human transcriber option.
|
|
87
|
+
* Use this option to specify up to 100 names of speakers in the transcript.
|
|
88
|
+
* Names may only be up to 50 characters long.
|
|
89
|
+
*/
|
|
90
|
+
speaker_names?: Array<{
|
|
91
|
+
/**
|
|
92
|
+
* The name of the speaker to be used when labeling monologues. Max of 50 characters.
|
|
93
|
+
*/
|
|
94
|
+
display_name: string;
|
|
95
|
+
}> | null;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Specify if speaker diarization will be skipped by the speech engine
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
skip_diarization?: boolean | null;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Only available for English and Spanish languages.
|
|
105
|
+
* User-supplied preference on whether to skip post-processing operations such as inverse text normalization (ITN), casing and punctuation.
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
skip_postprocessing?: boolean | null;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Specify if "punct" type elements will be skipped by the speech engine.
|
|
112
|
+
* For JSON outputs, this includes removing spaces. For text outputs, words will still be delimited by a space
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
skip_punctuation?: boolean | null;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Currently we only define disfluencies as 'ums' and 'uhs'.
|
|
119
|
+
* When set to true, disfluencies will not appear in the transcript.
|
|
120
|
+
* This option also removes atmospherics if the remove_atmospherics is not set.
|
|
121
|
+
* This option is not available for human transcription jobs.
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
124
|
+
remove_disfluencies?: boolean | null;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* We define many atmospherics such <laugh>, <affirmative> etc.
|
|
128
|
+
* When set to true, atmospherics will not appear in the transcript.
|
|
129
|
+
* This option is not available for human transcription jobs.
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
remove_atmospherics?: boolean | null;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Enabling this option will filter for approx. 600 profanities, which cover most use cases.
|
|
136
|
+
* If a transcribed word matches a word on this list, then all the characters of that word will be replaced by asterisks
|
|
137
|
+
* except for the first and last character.
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
filter_profanity?: boolean | null;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Only available for English, Spanish and French languages.
|
|
144
|
+
* Use to specify the total number of unique speaker channels in the audio.
|
|
145
|
+
*
|
|
146
|
+
* Given the number of audio channels provided, each channel will be transcribed separately and the channel id assigned to the speaker label.
|
|
147
|
+
* The final output will be a combination of all individual channel outputs.
|
|
148
|
+
* Overlapping monologues will have ordering broken by the order in which the first spoken element of each monologue occurs.
|
|
149
|
+
* If speaker_channels_count is greater than the actual channels in the audio, the job will fail with invalid_media.
|
|
150
|
+
* This option is not available for human transcription jobs.
|
|
151
|
+
*/
|
|
152
|
+
speaker_channels_count?: number | null;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Only available for English, Spanish and French languages.
|
|
156
|
+
* Use to specify the total number of unique speakers in the audio.
|
|
157
|
+
*
|
|
158
|
+
* Given the count of speakers provided, it will be used to improve the diarization accuracy.
|
|
159
|
+
* This option is not available for human transcription jobs.
|
|
160
|
+
* @default null
|
|
161
|
+
*/
|
|
162
|
+
speakers_count?: number | null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Use to specify diarization type. This option is not available for human transcription jobs and low-cost environment.
|
|
166
|
+
* @default "standard"
|
|
167
|
+
*/
|
|
168
|
+
diarization_type?: 'standard' | 'premium' | null;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* This feature is in beta. You can supply the id of a pre-completed custom vocabulary that you submitted through the Custom Vocabularies API
|
|
172
|
+
* instead of uploading the list of phrases using the custom_vocabularies parameter.
|
|
173
|
+
* Using custom_vocabulary_id or custom_vocabularies with the same list of phrases yields the same transcription result,
|
|
174
|
+
* but custom_vocabulary_id enables your submission to finish processing faster by 6 seconds on average.
|
|
175
|
+
*
|
|
176
|
+
* You cannot use both custom_vocabulary_id and custom_vocabularies at the same time, and doing so will result in a 400 response.
|
|
177
|
+
* If the supplied id represents an incomplete, deleted, or non-existent custom vocabulary then you will receive a 404 response.
|
|
178
|
+
*/
|
|
179
|
+
custom_vocabulary_id?: string | null;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Specify a collection of custom vocabulary to be used for this job.
|
|
183
|
+
* Custom vocabulary informs and biases the speech recognition to find those phrases (at the cost of slightly slower transcription).
|
|
184
|
+
*/
|
|
185
|
+
custom_vocabularies?: Array<object>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* If true, only exact phrases will be used as custom vocabulary, i.e. phrases will not be split into individual words for processing.
|
|
189
|
+
* By default is enabled.
|
|
190
|
+
*/
|
|
191
|
+
strict_custom_vocabulary?: boolean;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Use to specify summarization options. This option is not available for human transcription jobs.
|
|
195
|
+
*/
|
|
196
|
+
summarization_config?: {
|
|
197
|
+
/**
|
|
198
|
+
* Model type for summarization.
|
|
199
|
+
* @default "standard"
|
|
200
|
+
*/
|
|
201
|
+
model?: 'standard' | 'premium' | null;
|
|
202
|
+
/**
|
|
203
|
+
* Summarization formatting type. Use Paragraph for a text summary or Bullets for a list of topics.
|
|
204
|
+
* prompt and type parameters are mutuially exclusive.
|
|
205
|
+
* @default "paragraph"
|
|
206
|
+
*/
|
|
207
|
+
type?: 'paragraph' | 'bullets' | null;
|
|
208
|
+
/**
|
|
209
|
+
* Custom prompt. Provides the most flexible way to create summaries, but may lead to unpredictable results.
|
|
210
|
+
* Summary is produced in Markdown format.
|
|
211
|
+
* prompt and type parameters are mutuially exclusive.
|
|
212
|
+
*/
|
|
213
|
+
prompt?: string | null;
|
|
214
|
+
} | null;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Use to specify translation options. This option is not available for human transcription jobs.
|
|
218
|
+
*/
|
|
219
|
+
translation_config?: {
|
|
220
|
+
/**
|
|
221
|
+
* Target languages for translation.
|
|
222
|
+
*/
|
|
223
|
+
target_languages: Array<{
|
|
224
|
+
/**
|
|
225
|
+
* Target language for translation.
|
|
226
|
+
*/
|
|
227
|
+
language:
|
|
228
|
+
| 'en'
|
|
229
|
+
| 'en-us'
|
|
230
|
+
| 'en-gb'
|
|
231
|
+
| 'ar'
|
|
232
|
+
| 'pt'
|
|
233
|
+
| 'pt-br'
|
|
234
|
+
| 'pt-pt'
|
|
235
|
+
| 'fr'
|
|
236
|
+
| 'fr-ca'
|
|
237
|
+
| 'es'
|
|
238
|
+
| 'es-es'
|
|
239
|
+
| 'es-la'
|
|
240
|
+
| 'it'
|
|
241
|
+
| 'ja'
|
|
242
|
+
| 'ko'
|
|
243
|
+
| 'de'
|
|
244
|
+
| 'ru';
|
|
245
|
+
}>;
|
|
246
|
+
/**
|
|
247
|
+
* Model type for translation.
|
|
248
|
+
* @default "standard"
|
|
249
|
+
*/
|
|
250
|
+
model?: 'standard' | 'premium' | null;
|
|
251
|
+
} | null;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Language is provided as a ISO 639-1 language code, with exceptions.
|
|
255
|
+
* Only 1 language can be selected per audio, i.e. no multiple languages in one transcription job.
|
|
256
|
+
* @default "en"
|
|
257
|
+
*/
|
|
258
|
+
language?: string | null;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Provides improved accuracy for per-word timestamps for a transcript.
|
|
262
|
+
*
|
|
263
|
+
* The following languages are currently supported:
|
|
264
|
+
* - English (en, en-us, en-gb)
|
|
265
|
+
* - French (fr)
|
|
266
|
+
* - Italian (it)
|
|
267
|
+
* - German (de)
|
|
268
|
+
* - Spanish (es)
|
|
269
|
+
*
|
|
270
|
+
* This option is not available in low-cost environment
|
|
271
|
+
* @default false
|
|
272
|
+
*/
|
|
273
|
+
forced_alignment?: boolean | null;
|
|
274
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
2
|
+
|
|
3
|
+
export type RevaiConfig = {
|
|
4
|
+
provider: string;
|
|
5
|
+
url: (options: { modelId: string; path: string }) => string;
|
|
6
|
+
headers: () => Record<string, string | undefined>;
|
|
7
|
+
fetch?: FetchFunction;
|
|
8
|
+
generateId?: () => string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { safeParseJSON } from '@ai-sdk/provider-utils';
|
|
2
|
+
import { revaiErrorDataSchema } from './revai-error';
|
|
3
|
+
import { describe, it, expect } from 'vitest';
|
|
4
|
+
|
|
5
|
+
describe('revaiErrorDataSchema', () => {
|
|
6
|
+
it('should parse Rev.ai resource exhausted error', async () => {
|
|
7
|
+
const error = `
|
|
8
|
+
{"error":{"message":"{\\n \\"error\\": {\\n \\"code\\": 429,\\n \\"message\\": \\"Resource has been exhausted (e.g. check quota).\\",\\n \\"status\\": \\"RESOURCE_EXHAUSTED\\"\\n }\\n}\\n","code":429}}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const result = await safeParseJSON({
|
|
12
|
+
text: error,
|
|
13
|
+
schema: revaiErrorDataSchema,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(result).toStrictEqual({
|
|
17
|
+
success: true,
|
|
18
|
+
value: {
|
|
19
|
+
error: {
|
|
20
|
+
message:
|
|
21
|
+
'{\n "error": {\n "code": 429,\n "message": "Resource has been exhausted (e.g. check quota).",\n "status": "RESOURCE_EXHAUSTED"\n }\n}\n',
|
|
22
|
+
code: 429,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
rawValue: {
|
|
26
|
+
error: {
|
|
27
|
+
message:
|
|
28
|
+
'{\n "error": {\n "code": 429,\n "message": "Resource has been exhausted (e.g. check quota).",\n "status": "RESOURCE_EXHAUSTED"\n }\n}\n',
|
|
29
|
+
code: 429,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
export const revaiErrorDataSchema = z.object({
|
|
5
|
+
error: z.object({
|
|
6
|
+
message: z.string(),
|
|
7
|
+
code: z.number(),
|
|
8
|
+
}),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type RevaiErrorData = z.infer<typeof revaiErrorDataSchema>;
|
|
12
|
+
|
|
13
|
+
export const revaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
14
|
+
errorSchema: revaiErrorDataSchema,
|
|
15
|
+
errorToMessage: data => data.error.message,
|
|
16
|
+
});
|