@mastra/voice-gladia 0.0.0-message-list-update-20250715150321 → 0.0.0-new-scorer-api-20250801075530
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.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +37 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -6
- package/dist/_tsup-dts-rollup.d.cts +0 -40
- package/dist/_tsup-dts-rollup.d.ts +0 -40
- package/dist/index.d.cts +0 -4
package/dist/index.cjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["MastraVoice"],"mappings":";;;;;AA6BO,IAAM,WAAA,GAAN,cAA0BA,iBAAA,CAAY;AAAA,EACnC,MAAA;AAAA,EACA,OAAA,GAAU,0BAAA;AAAA,EAElB,WAAA,CAAY,EAAE,cAAA,EAAe,GAAuC,EAAC,EAAG;AACtE,IAAA,MAAM,aAAA,GAAgB,QAAQ,GAAA,CAAI,cAAA;AAClC,IAAA,KAAA,CAAM;AAAA,MACJ,cAAA,EAAgB;AAAA,QACd,IAAA,EAAM,QAAA;AAAA,QACN,MAAA,EAAQ,gBAAgB,MAAA,IAAU;AAAA;AACpC,KACD,CAAA;AAED,IAAA,IAAA,CAAK,MAAA,GAAS,KAAK,cAAA,EAAgB,MAAA;AACnC,IAAA,IAAI,CAAC,IAAA,CAAK,MAAA,EAAQ,MAAM,IAAI,MAAM,4BAA4B,CAAA;AAAA,EAChE;AAAA,EAEA,MAAM,KAAA,CAAM,MAAA,EAAgB,QAAA,EAAkD;AAC5E,IAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,EAC3D;AAAA,EAEA,MAAM,MAAA,CAAO,KAAA,EAAiB,EAAE,QAAA,EAAU,QAAA,EAAU,SAAQ,EAA4C;AACtG,IAAA,OAAO,IAAA,CAAK,OAAO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cAAA,EAAiB,QAAA,CAAS,KAAA,IAAS,SAAS,CAAA,CAAE,CAAA;AAAA,QAChE;AAEA,QAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,GAAA,KAAO,UAAA,CAAW,GAAA,EAAK,GAAI,CAAC,CAAA;AAAA,MAChD;AAAA,IACF,CAAA,EAAG,qBAAqB,CAAA,EAAE;AAAA,EAC5B;AACF","file":"index.cjs","sourcesContent":["import type { Readable } from 'stream';\nimport { MastraVoice } from '@mastra/core/voice';\n\ninterface GladiaConfig {\n apiKey: string;\n}\n\ninterface GladiaListenOptions {\n diarization?: boolean;\n diarization_config?: {\n number_of_speakers?: number;\n min_speakers?: number;\n max_speakers?: number;\n };\n translation?: boolean;\n translation_config?: {\n model?: 'base' | 'enhanced';\n target_languages?: string[];\n };\n detect_language?: boolean;\n enable_code_switching?: boolean;\n}\n\ninterface GladiaListenCallParams {\n mimeType: string;\n fileName: string;\n options?: GladiaListenOptions;\n}\n\nexport class GladiaVoice extends MastraVoice {\n private apiKey: string;\n private baseUrl = 'https://api.gladia.io/v2';\n\n constructor({ listeningModel }: { listeningModel?: GladiaConfig } = {}) {\n const defaultApiKey = process.env.GLADIA_API_KEY;\n super({\n listeningModel: {\n name: 'gladia',\n apiKey: listeningModel?.apiKey ?? defaultApiKey,\n },\n });\n\n this.apiKey = this.listeningModel?.apiKey as string;\n if (!this.apiKey) throw new Error('GLADIA_API_KEY is not set.');\n }\n\n async speak(_input: string, _options?: Record<string, unknown>): Promise<any> {\n throw new Error('Gladia does not support text-to-speech.');\n }\n\n async listen(input: Readable, { mimeType, fileName, options }: GladiaListenCallParams): Promise<string> {\n return this.traced(async () => {\n if (!fileName) {\n throw new Error('fileName is required for audio processing');\n }\n if (!mimeType) {\n throw new Error('mimeType is required for audio processing');\n }\n const chunks: Buffer[] = [];\n for await (const chunk of input) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);\n }\n\n const audioBuffer = Buffer.concat(chunks);\n const form = new FormData();\n form.append('audio', new Blob([audioBuffer], { type: mimeType }), fileName);\n\n const uploadRes: any = await fetch(`${this.baseUrl}/upload/`, {\n method: 'POST',\n headers: { 'x-gladia-key': this.apiKey },\n body: form,\n });\n if (!uploadRes.ok) {\n throw new Error(`Upload failed: ${uploadRes.status} ${await uploadRes.text()}`);\n }\n const { audio_url } = await uploadRes.json();\n const opts: GladiaListenOptions = {\n diarization: true, // <-- default\n ...options,\n };\n\n const transcribeRes: any = await fetch(`${this.baseUrl}/pre-recorded/`, {\n method: 'POST',\n headers: {\n 'x-gladia-key': this.apiKey,\n 'Content-Type': 'application/json',\n },\n\n body: JSON.stringify({ audio_url, ...opts }),\n });\n\n const { id } = await transcribeRes.json();\n\n while (true) {\n const pollRes: any = await fetch(`${this.baseUrl}/pre-recorded/${id}`, {\n method: 'GET',\n headers: {\n 'x-gladia-key': this.apiKey,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!pollRes.ok) {\n throw new Error(`Polling failed: ${pollRes.status} ${await pollRes.text()}`);\n }\n\n const pollJson = await pollRes.json();\n if (pollJson.status === 'done') {\n const transcript = pollJson.result?.transcription?.full_transcript;\n if (!transcript) throw new Error('No transcript found');\n return transcript;\n }\n\n if (pollJson.status === 'error') {\n throw new Error(`Gladia error: ${pollJson.error || 'Unknown'}`);\n }\n\n await new Promise(res => setTimeout(res, 1000));\n }\n }, 'voice.gladia.listen')();\n }\n}\n\nexport type { GladiaConfig, GladiaListenOptions };\nexport type { GladiaListenCallParams };\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { Readable } from 'stream';
|
|
2
|
+
import { MastraVoice } from '@mastra/core/voice';
|
|
3
|
+
interface GladiaConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
}
|
|
6
|
+
interface GladiaListenOptions {
|
|
7
|
+
diarization?: boolean;
|
|
8
|
+
diarization_config?: {
|
|
9
|
+
number_of_speakers?: number;
|
|
10
|
+
min_speakers?: number;
|
|
11
|
+
max_speakers?: number;
|
|
12
|
+
};
|
|
13
|
+
translation?: boolean;
|
|
14
|
+
translation_config?: {
|
|
15
|
+
model?: 'base' | 'enhanced';
|
|
16
|
+
target_languages?: string[];
|
|
17
|
+
};
|
|
18
|
+
detect_language?: boolean;
|
|
19
|
+
enable_code_switching?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface GladiaListenCallParams {
|
|
22
|
+
mimeType: string;
|
|
23
|
+
fileName: string;
|
|
24
|
+
options?: GladiaListenOptions;
|
|
25
|
+
}
|
|
26
|
+
export declare class GladiaVoice extends MastraVoice {
|
|
27
|
+
private apiKey;
|
|
28
|
+
private baseUrl;
|
|
29
|
+
constructor({ listeningModel }?: {
|
|
30
|
+
listeningModel?: GladiaConfig;
|
|
31
|
+
});
|
|
32
|
+
speak(_input: string, _options?: Record<string, unknown>): Promise<any>;
|
|
33
|
+
listen(input: Readable, { mimeType, fileName, options }: GladiaListenCallParams): Promise<string>;
|
|
34
|
+
}
|
|
35
|
+
export type { GladiaConfig, GladiaListenOptions };
|
|
36
|
+
export type { GladiaListenCallParams };
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,mBAAmB;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE;QACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF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AAM,IAAI,KAAA,CAAM,CAAA,gBAAA,EAAmB,OAAA,CAAQ,MAAM,IAAI,MAAM,OAAA,CAAQ,IAAA,EAAM,CAAA,CAAE,CAAA;AAAA,QAC7E;AAEA,QAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,IAAA,EAAK;AACpC,QAAA,IAAI,QAAA,CAAS,WAAW,MAAA,EAAQ;AAC9B,UAAA,MAAM,UAAA,GAAa,QAAA,CAAS,MAAA,EAAQ,aAAA,EAAe,eAAA;AACnD,UAAA,IAAI,CAAC,UAAA,EAAY,MAAM,IAAI,MAAM,qBAAqB,CAAA;AACtD,UAAA,OAAO,UAAA;AAAA,QACT;AAEA,QAAA,IAAI,QAAA,CAAS,WAAW,OAAA,EAAS;AAC/B,UAAA,MAAM,IAAI,KAAA,CAAM,CAAA,cAAA,EAAiB,QAAA,CAAS,KAAA,IAAS,SAAS,CAAA,CAAE,CAAA;AAAA,QAChE;AAEA,QAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,GAAA,KAAO,UAAA,CAAW,GAAA,EAAK,GAAI,CAAC,CAAA;AAAA,MAChD;AAAA,IACF,CAAA,EAAG,qBAAqB,CAAA,EAAE;AAAA,EAC5B;AACF","file":"index.js","sourcesContent":["import type { Readable } from 'stream';\nimport { MastraVoice } from '@mastra/core/voice';\n\ninterface GladiaConfig {\n apiKey: string;\n}\n\ninterface GladiaListenOptions {\n diarization?: boolean;\n diarization_config?: {\n number_of_speakers?: number;\n min_speakers?: number;\n max_speakers?: number;\n };\n translation?: boolean;\n translation_config?: {\n model?: 'base' | 'enhanced';\n target_languages?: string[];\n };\n detect_language?: boolean;\n enable_code_switching?: boolean;\n}\n\ninterface GladiaListenCallParams {\n mimeType: string;\n fileName: string;\n options?: GladiaListenOptions;\n}\n\nexport class GladiaVoice extends MastraVoice {\n private apiKey: string;\n private baseUrl = 'https://api.gladia.io/v2';\n\n constructor({ listeningModel }: { listeningModel?: GladiaConfig } = {}) {\n const defaultApiKey = process.env.GLADIA_API_KEY;\n super({\n listeningModel: {\n name: 'gladia',\n apiKey: listeningModel?.apiKey ?? defaultApiKey,\n },\n });\n\n this.apiKey = this.listeningModel?.apiKey as string;\n if (!this.apiKey) throw new Error('GLADIA_API_KEY is not set.');\n }\n\n async speak(_input: string, _options?: Record<string, unknown>): Promise<any> {\n throw new Error('Gladia does not support text-to-speech.');\n }\n\n async listen(input: Readable, { mimeType, fileName, options }: GladiaListenCallParams): Promise<string> {\n return this.traced(async () => {\n if (!fileName) {\n throw new Error('fileName is required for audio processing');\n }\n if (!mimeType) {\n throw new Error('mimeType is required for audio processing');\n }\n const chunks: Buffer[] = [];\n for await (const chunk of input) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);\n }\n\n const audioBuffer = Buffer.concat(chunks);\n const form = new FormData();\n form.append('audio', new Blob([audioBuffer], { type: mimeType }), fileName);\n\n const uploadRes: any = await fetch(`${this.baseUrl}/upload/`, {\n method: 'POST',\n headers: { 'x-gladia-key': this.apiKey },\n body: form,\n });\n if (!uploadRes.ok) {\n throw new Error(`Upload failed: ${uploadRes.status} ${await uploadRes.text()}`);\n }\n const { audio_url } = await uploadRes.json();\n const opts: GladiaListenOptions = {\n diarization: true, // <-- default\n ...options,\n };\n\n const transcribeRes: any = await fetch(`${this.baseUrl}/pre-recorded/`, {\n method: 'POST',\n headers: {\n 'x-gladia-key': this.apiKey,\n 'Content-Type': 'application/json',\n },\n\n body: JSON.stringify({ audio_url, ...opts }),\n });\n\n const { id } = await transcribeRes.json();\n\n while (true) {\n const pollRes: any = await fetch(`${this.baseUrl}/pre-recorded/${id}`, {\n method: 'GET',\n headers: {\n 'x-gladia-key': this.apiKey,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!pollRes.ok) {\n throw new Error(`Polling failed: ${pollRes.status} ${await pollRes.text()}`);\n }\n\n const pollJson = await pollRes.json();\n if (pollJson.status === 'done') {\n const transcript = pollJson.result?.transcription?.full_transcript;\n if (!transcript) throw new Error('No transcript found');\n return transcript;\n }\n\n if (pollJson.status === 'error') {\n throw new Error(`Gladia error: ${pollJson.error || 'Unknown'}`);\n }\n\n await new Promise(res => setTimeout(res, 1000));\n }\n }, 'voice.gladia.listen')();\n }\n}\n\nexport type { GladiaConfig, GladiaListenOptions };\nexport type { GladiaListenCallParams };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/voice-gladia",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-new-scorer-api-20250801075530",
|
|
4
4
|
"description": "Mastra Gladia AI voice integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"tsup": "^8.4.0",
|
|
34
34
|
"typescript": "^5.8.3",
|
|
35
35
|
"vitest": "^3.2.4",
|
|
36
|
-
"@internal/lint": "0.0.0-
|
|
37
|
-
"@mastra/core": "0.0.0-
|
|
36
|
+
"@internal/lint": "0.0.0-new-scorer-api-20250801075530",
|
|
37
|
+
"@mastra/core": "0.0.0-new-scorer-api-20250801075530"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"mastra",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"speech-recognition"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@mastra/core": "0.0.0-
|
|
47
|
+
"@mastra/core": "0.0.0-new-scorer-api-20250801075530"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "tsup
|
|
51
|
-
"build:watch": "
|
|
50
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
51
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
52
52
|
"test": "vitest run",
|
|
53
53
|
"test:watch": "vitest watch",
|
|
54
54
|
"lint": "eslint ."
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { MastraVoice } from '@mastra/core/voice';
|
|
2
|
-
import type { Readable } from 'stream';
|
|
3
|
-
|
|
4
|
-
export declare interface GladiaConfig {
|
|
5
|
-
apiKey: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export declare interface GladiaListenCallParams {
|
|
9
|
-
mimeType: string;
|
|
10
|
-
fileName: string;
|
|
11
|
-
options?: GladiaListenOptions;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export declare interface GladiaListenOptions {
|
|
15
|
-
diarization?: boolean;
|
|
16
|
-
diarization_config?: {
|
|
17
|
-
number_of_speakers?: number;
|
|
18
|
-
min_speakers?: number;
|
|
19
|
-
max_speakers?: number;
|
|
20
|
-
};
|
|
21
|
-
translation?: boolean;
|
|
22
|
-
translation_config?: {
|
|
23
|
-
model?: 'base' | 'enhanced';
|
|
24
|
-
target_languages?: string[];
|
|
25
|
-
};
|
|
26
|
-
detect_language?: boolean;
|
|
27
|
-
enable_code_switching?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export declare class GladiaVoice extends MastraVoice {
|
|
31
|
-
private apiKey;
|
|
32
|
-
private baseUrl;
|
|
33
|
-
constructor({ listeningModel }?: {
|
|
34
|
-
listeningModel?: GladiaConfig;
|
|
35
|
-
});
|
|
36
|
-
speak(_input: string, _options?: Record<string, unknown>): Promise<any>;
|
|
37
|
-
listen(input: Readable, { mimeType, fileName, options }: GladiaListenCallParams): Promise<string>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { }
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { MastraVoice } from '@mastra/core/voice';
|
|
2
|
-
import type { Readable } from 'stream';
|
|
3
|
-
|
|
4
|
-
export declare interface GladiaConfig {
|
|
5
|
-
apiKey: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export declare interface GladiaListenCallParams {
|
|
9
|
-
mimeType: string;
|
|
10
|
-
fileName: string;
|
|
11
|
-
options?: GladiaListenOptions;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export declare interface GladiaListenOptions {
|
|
15
|
-
diarization?: boolean;
|
|
16
|
-
diarization_config?: {
|
|
17
|
-
number_of_speakers?: number;
|
|
18
|
-
min_speakers?: number;
|
|
19
|
-
max_speakers?: number;
|
|
20
|
-
};
|
|
21
|
-
translation?: boolean;
|
|
22
|
-
translation_config?: {
|
|
23
|
-
model?: 'base' | 'enhanced';
|
|
24
|
-
target_languages?: string[];
|
|
25
|
-
};
|
|
26
|
-
detect_language?: boolean;
|
|
27
|
-
enable_code_switching?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export declare class GladiaVoice extends MastraVoice {
|
|
31
|
-
private apiKey;
|
|
32
|
-
private baseUrl;
|
|
33
|
-
constructor({ listeningModel }?: {
|
|
34
|
-
listeningModel?: GladiaConfig;
|
|
35
|
-
});
|
|
36
|
-
speak(_input: string, _options?: Record<string, unknown>): Promise<any>;
|
|
37
|
-
listen(input: Readable, { mimeType, fileName, options }: GladiaListenCallParams): Promise<string>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { }
|
package/dist/index.d.cts
DELETED