@moxxy/plugin-stt-whisper 0.45.0 → 0.46.0
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/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -25
- package/dist/index.js.map +1 -1
- package/dist/whisper.d.ts +1 -1
- package/dist/whisper.d.ts.map +1 -1
- package/dist/whisper.js +2 -2
- package/dist/whisper.js.map +1 -1
- package/package.json +2 -2
- package/src/index.test.ts +13 -0
- package/src/index.ts +14 -14
- package/src/whisper.ts +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface BuildWhisperPluginOptions {
|
|
|
8
8
|
* without an explicit config. Defaults to `whisper-1`.
|
|
9
9
|
*/
|
|
10
10
|
readonly model?: WhisperModel;
|
|
11
|
+
/** Register one transcriber per model instead (overrides `model`). */
|
|
12
|
+
readonly models?: ReadonlyArray<WhisperModel>;
|
|
11
13
|
/**
|
|
12
14
|
* Optional default config baked into the transcriber def. Callers can
|
|
13
15
|
* still override per-`setActive(name, config)`.
|
|
@@ -15,17 +17,14 @@ export interface BuildWhisperPluginOptions {
|
|
|
15
17
|
readonly defaults?: Omit<WhisperTranscriberOptions, 'client'>;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
|
-
* Build the @moxxy/plugin-stt-whisper plugin
|
|
19
|
-
*
|
|
20
|
+
* Build the @moxxy/plugin-stt-whisper plugin: one transcriber per model, each
|
|
21
|
+
* named `openai-<model>` (one model unless `models` lists several).
|
|
20
22
|
*
|
|
21
|
-
* To run several
|
|
22
|
-
*
|
|
23
|
-
* `openai-gpt-4o-transcribe`), but each registration carries the SAME
|
|
24
|
-
* plugin name, so the host must register them under DISTINCT plugin names
|
|
25
|
-
* (the name-keyed plugin registry would otherwise clobber the first).
|
|
23
|
+
* To run several models at once, pass `models` — the transcriber names
|
|
24
|
+
* won't collide (`openai-gpt-transcribe` vs `openai-whisper-1`).
|
|
26
25
|
*
|
|
27
26
|
* Activation:
|
|
28
|
-
* session.transcribers.setActive('openai-
|
|
27
|
+
* session.transcribers.setActive('openai-gpt-transcribe', { apiKey: ... });
|
|
29
28
|
*
|
|
30
29
|
* The plugin is intentionally side-effect free — registering it does
|
|
31
30
|
* NOT activate the transcriber. The host (CLI / config loader) chooses
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAErG,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;CAC/D;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAErG,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;CAC/D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,yBAA8B,GAAG,MAAM,CAoB/E;;AAKD,wBAA+E"}
|
package/dist/index.js
CHANGED
|
@@ -3,17 +3,14 @@ import { WhisperTranscriber } from './whisper.js';
|
|
|
3
3
|
export { WhisperTranscriber, createWhisperTranscriber, } from './whisper.js';
|
|
4
4
|
export { MOXXY_PCM16_24KHZ_MIME, WHISPER_FILENAME_BY_MIME, normalizeWhisperUpload, pcm16MonoToWav, } from './audio.js';
|
|
5
5
|
/**
|
|
6
|
-
* Build the @moxxy/plugin-stt-whisper plugin
|
|
7
|
-
*
|
|
6
|
+
* Build the @moxxy/plugin-stt-whisper plugin: one transcriber per model, each
|
|
7
|
+
* named `openai-<model>` (one model unless `models` lists several).
|
|
8
8
|
*
|
|
9
|
-
* To run several
|
|
10
|
-
*
|
|
11
|
-
* `openai-gpt-4o-transcribe`), but each registration carries the SAME
|
|
12
|
-
* plugin name, so the host must register them under DISTINCT plugin names
|
|
13
|
-
* (the name-keyed plugin registry would otherwise clobber the first).
|
|
9
|
+
* To run several models at once, pass `models` — the transcriber names
|
|
10
|
+
* won't collide (`openai-gpt-transcribe` vs `openai-whisper-1`).
|
|
14
11
|
*
|
|
15
12
|
* Activation:
|
|
16
|
-
* session.transcribers.setActive('openai-
|
|
13
|
+
* session.transcribers.setActive('openai-gpt-transcribe', { apiKey: ... });
|
|
17
14
|
*
|
|
18
15
|
* The plugin is intentionally side-effect free — registering it does
|
|
19
16
|
* NOT activate the transcriber. The host (CLI / config loader) chooses
|
|
@@ -21,27 +18,26 @@ export { MOXXY_PCM16_24KHZ_MIME, WHISPER_FILENAME_BY_MIME, normalizeWhisperUploa
|
|
|
21
18
|
* outbound calls to OpenAI.
|
|
22
19
|
*/
|
|
23
20
|
export function buildWhisperPlugin(opts = {}) {
|
|
24
|
-
const
|
|
25
|
-
const name = `openai-${model}`;
|
|
21
|
+
const models = opts.models ?? [opts.model ?? 'whisper-1'];
|
|
26
22
|
return definePlugin({
|
|
27
23
|
name: '@moxxy/plugin-stt-whisper',
|
|
28
24
|
version: '0.0.0',
|
|
29
|
-
transcribers:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}),
|
|
42
|
-
],
|
|
25
|
+
transcribers: models.map((model) => defineTranscriber({
|
|
26
|
+
name: `openai-${model}`,
|
|
27
|
+
displayName: `OpenAI ${model}`,
|
|
28
|
+
createClient: (config) => {
|
|
29
|
+
const merged = {
|
|
30
|
+
...(opts.defaults ?? {}),
|
|
31
|
+
...config,
|
|
32
|
+
model,
|
|
33
|
+
};
|
|
34
|
+
return new WhisperTranscriber(merged);
|
|
35
|
+
},
|
|
36
|
+
})),
|
|
43
37
|
});
|
|
44
38
|
}
|
|
45
39
|
// Discovery entry: `createPluginLoader` requires a default Plugin export.
|
|
46
|
-
|
|
40
|
+
// `gpt-transcribe` is OpenAI's current model; `whisper-1` (deprecated by
|
|
41
|
+
// OpenAI) stays registered for configs that already name it.
|
|
42
|
+
export default buildWhisperPlugin({ models: ['gpt-transcribe', 'whisper-1'] });
|
|
47
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAe,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAqD,MAAM,cAAc,CAAC;AAErG,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,GAEf,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAe,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAqD,MAAM,cAAc,CAAC;AAErG,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,GAEf,MAAM,YAAY,CAAC;AAiBpB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkC,EAAE;IACrE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC;IAC1D,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,2BAA2B;QACjC,OAAO,EAAE,OAAO;QAChB,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACjC,iBAAiB,CAAC;YAChB,IAAI,EAAE,UAAU,KAAK,EAAE;YACvB,WAAW,EAAE,UAAU,KAAK,EAAE;YAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;gBACvB,MAAM,MAAM,GAA8B;oBACxC,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;oBACxB,GAAI,MAAoC;oBACxC,KAAK;iBACN,CAAC;gBACF,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;SACF,CAAC,CACH;KACF,CAAC,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,yEAAyE;AACzE,6DAA6D;AAC7D,eAAe,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC"}
|
package/dist/whisper.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
2
|
import { type Transcriber, type TranscribeOptions, type TranscriptionResult } from '@moxxy/sdk';
|
|
3
|
-
export type WhisperModel = 'whisper-1' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
|
|
3
|
+
export type WhisperModel = 'whisper-1' | 'gpt-transcribe' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
|
|
4
4
|
export interface WhisperTranscriberOptions {
|
|
5
5
|
readonly apiKey?: string;
|
|
6
6
|
readonly baseURL?: string;
|
package/dist/whisper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whisper.d.ts","sourceRoot":"","sources":["../src/whisper.ts"],"names":[],"mappings":"AAAA,OAAO,MAA2D,MAAM,QAAQ,CAAC;AACjF,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"whisper.d.ts","sourceRoot":"","sources":["../src/whisper.ts"],"names":[],"mappings":"AAAA,OAAO,MAA2D,MAAM,QAAQ,CAAC;AACjF,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;AAK3G,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;gBAEzC,IAAI,GAAE,yBAA8B;IAY1C,UAAU,CACd,KAAK,EAAE,UAAU,GAAG,WAAW,EAC/B,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IAkE/B;;;;OAIG;YACW,GAAG;CA0BlB;AAqDD,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,yBAA8B,GAAG,kBAAkB,CAEjG"}
|
package/dist/whisper.js
CHANGED
|
@@ -37,8 +37,8 @@ export class WhisperTranscriber {
|
|
|
37
37
|
// an `Uploadable`.
|
|
38
38
|
const file = new File([upload.bytes], upload.filename, { type: upload.mimeType });
|
|
39
39
|
const language = opts.language ?? this.defaultLanguage;
|
|
40
|
-
// verbose_json is only supported by whisper-1;
|
|
41
|
-
//
|
|
40
|
+
// verbose_json is only supported by whisper-1; gpt-transcribe and the
|
|
41
|
+
// gpt-4o family return plain JSON. Branch so callers get rich segments when
|
|
42
42
|
// available, and a graceful text-only result when not.
|
|
43
43
|
if (this.model === 'whisper-1') {
|
|
44
44
|
const response = await this.run(() => this.client.audio.transcriptions.create({
|
package/dist/whisper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whisper.js","sourceRoot":"","sources":["../src/whisper.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,GAIX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAIpD,yEAAyE;AACzE,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAgBrC;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAkB;IACpB,IAAI,CAAS;IACL,MAAM,CAAS;IACf,KAAK,CAAe;IACpB,eAAe,CAAqB;IAErD,YAAY,OAAkC,EAAE;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,WAAW,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC;QACrC,IAAI,CAAC,MAAM;YACT,IAAI,CAAC,MAAM;gBACX,IAAI,MAAM,CAAC;oBACT,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;oBACjD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACnD,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,UAAU,CACd,KAA+B,EAC/B,OAA0B,EAAE;QAE5B,wEAAwE;QACxE,4EAA4E;QAC5E,0EAA0E;QAC1E,mEAAmE;QACnE,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ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Audio bytes → text + segments. Plugs into the session's TranscriberRegistry; channels with audio input (Telegram voice, HTTP multipart) consume it transparently.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"openai": "^7.31.0",
|
|
47
|
-
"@moxxy/sdk": "0.
|
|
47
|
+
"@moxxy/sdk": "0.46.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^22.20.5",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import plugin, { buildWhisperPlugin } from './index.js';
|
|
3
|
+
|
|
4
|
+
describe('@moxxy/plugin-stt-whisper', () => {
|
|
5
|
+
it('registers the current OpenAI model and keeps whisper-1 for existing configs', () => {
|
|
6
|
+
expect(plugin.transcribers?.map((def) => def.name)).toEqual(['openai-gpt-transcribe', 'openai-whisper-1']);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('still builds a single-model plugin on request', () => {
|
|
10
|
+
expect(buildWhisperPlugin({ model: 'gpt-4o-transcribe' }).transcribers?.map((def) => def.name))
|
|
11
|
+
.toEqual(['openai-gpt-4o-transcribe']);
|
|
12
|
+
});
|
|
13
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface BuildWhisperPluginOptions {
|
|
|
21
21
|
* without an explicit config. Defaults to `whisper-1`.
|
|
22
22
|
*/
|
|
23
23
|
readonly model?: WhisperModel;
|
|
24
|
+
/** Register one transcriber per model instead (overrides `model`). */
|
|
25
|
+
readonly models?: ReadonlyArray<WhisperModel>;
|
|
24
26
|
/**
|
|
25
27
|
* Optional default config baked into the transcriber def. Callers can
|
|
26
28
|
* still override per-`setActive(name, config)`.
|
|
@@ -29,17 +31,14 @@ export interface BuildWhisperPluginOptions {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
|
-
* Build the @moxxy/plugin-stt-whisper plugin
|
|
33
|
-
*
|
|
34
|
+
* Build the @moxxy/plugin-stt-whisper plugin: one transcriber per model, each
|
|
35
|
+
* named `openai-<model>` (one model unless `models` lists several).
|
|
34
36
|
*
|
|
35
|
-
* To run several
|
|
36
|
-
*
|
|
37
|
-
* `openai-gpt-4o-transcribe`), but each registration carries the SAME
|
|
38
|
-
* plugin name, so the host must register them under DISTINCT plugin names
|
|
39
|
-
* (the name-keyed plugin registry would otherwise clobber the first).
|
|
37
|
+
* To run several models at once, pass `models` — the transcriber names
|
|
38
|
+
* won't collide (`openai-gpt-transcribe` vs `openai-whisper-1`).
|
|
40
39
|
*
|
|
41
40
|
* Activation:
|
|
42
|
-
* session.transcribers.setActive('openai-
|
|
41
|
+
* session.transcribers.setActive('openai-gpt-transcribe', { apiKey: ... });
|
|
43
42
|
*
|
|
44
43
|
* The plugin is intentionally side-effect free — registering it does
|
|
45
44
|
* NOT activate the transcriber. The host (CLI / config loader) chooses
|
|
@@ -47,14 +46,13 @@ export interface BuildWhisperPluginOptions {
|
|
|
47
46
|
* outbound calls to OpenAI.
|
|
48
47
|
*/
|
|
49
48
|
export function buildWhisperPlugin(opts: BuildWhisperPluginOptions = {}): Plugin {
|
|
50
|
-
const
|
|
51
|
-
const name = `openai-${model}`;
|
|
49
|
+
const models = opts.models ?? [opts.model ?? 'whisper-1'];
|
|
52
50
|
return definePlugin({
|
|
53
51
|
name: '@moxxy/plugin-stt-whisper',
|
|
54
52
|
version: '0.0.0',
|
|
55
|
-
transcribers:
|
|
53
|
+
transcribers: models.map((model) =>
|
|
56
54
|
defineTranscriber({
|
|
57
|
-
name
|
|
55
|
+
name: `openai-${model}`,
|
|
58
56
|
displayName: `OpenAI ${model}`,
|
|
59
57
|
createClient: (config) => {
|
|
60
58
|
const merged: WhisperTranscriberOptions = {
|
|
@@ -65,9 +63,11 @@ export function buildWhisperPlugin(opts: BuildWhisperPluginOptions = {}): Plugin
|
|
|
65
63
|
return new WhisperTranscriber(merged);
|
|
66
64
|
},
|
|
67
65
|
}),
|
|
68
|
-
|
|
66
|
+
),
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
// Discovery entry: `createPluginLoader` requires a default Plugin export.
|
|
73
|
-
|
|
71
|
+
// `gpt-transcribe` is OpenAI's current model; `whisper-1` (deprecated by
|
|
72
|
+
// OpenAI) stays registered for configs that already name it.
|
|
73
|
+
export default buildWhisperPlugin({ models: ['gpt-transcribe', 'whisper-1'] });
|
package/src/whisper.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@moxxy/sdk';
|
|
10
10
|
import { normalizeWhisperUpload } from './audio.js';
|
|
11
11
|
|
|
12
|
-
export type WhisperModel = 'whisper-1' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
|
|
12
|
+
export type WhisperModel = 'whisper-1' | 'gpt-transcribe' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
|
|
13
13
|
|
|
14
14
|
/** Provider tag attached to classified errors for logs/debug context. */
|
|
15
15
|
const WHISPER_PROVIDER_ID = 'openai';
|
|
@@ -67,8 +67,8 @@ export class WhisperTranscriber implements Transcriber {
|
|
|
67
67
|
// an `Uploadable`.
|
|
68
68
|
const file = new File([upload.bytes], upload.filename, { type: upload.mimeType });
|
|
69
69
|
const language = opts.language ?? this.defaultLanguage;
|
|
70
|
-
// verbose_json is only supported by whisper-1;
|
|
71
|
-
//
|
|
70
|
+
// verbose_json is only supported by whisper-1; gpt-transcribe and the
|
|
71
|
+
// gpt-4o family return plain JSON. Branch so callers get rich segments when
|
|
72
72
|
// available, and a graceful text-only result when not.
|
|
73
73
|
if (this.model === 'whisper-1') {
|
|
74
74
|
const response = await this.run(() =>
|