@voquill/voice-ai 0.2.4 → 0.2.5
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.
|
@@ -2,5 +2,16 @@ export type ElevenLabsTestIntegrationArgs = {
|
|
|
2
2
|
apiKey: string;
|
|
3
3
|
};
|
|
4
4
|
export declare const elevenlabsTestIntegration: ({ apiKey, }: ElevenLabsTestIntegrationArgs) => Promise<boolean>;
|
|
5
|
+
export type ElevenLabsTranscriptionArgs = {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
blob: ArrayBuffer | Buffer;
|
|
8
|
+
ext: string;
|
|
9
|
+
language?: string;
|
|
10
|
+
};
|
|
11
|
+
export type ElevenLabsTranscribeAudioOutput = {
|
|
12
|
+
text: string;
|
|
13
|
+
wordsUsed: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const elevenlabsTranscribeAudio: ({ apiKey, blob, ext, language, }: ElevenLabsTranscriptionArgs) => Promise<ElevenLabsTranscribeAudioOutput>;
|
|
5
16
|
export declare const convertFloat32ToBase64PCM16: (float32Array: Float32Array | number[]) => string;
|
|
6
17
|
//# sourceMappingURL=elevenlabs.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs.utils.d.ts","sourceRoot":"","sources":["../src/elevenlabs.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"elevenlabs.utils.d.ts","sourceRoot":"","sources":["../src/elevenlabs.utils.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,aAE7C,6BAA6B,KAAG,OAAO,CAAC,OAAO,CAUjD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,kCAK7C,2BAA2B,KAAG,OAAO,CAAC,+BAA+B,CA4CvE,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,cAAc,YAAY,GAAG,MAAM,EAAE,KACpC,MAmBF,CAAC"}
|
package/dist/elevenlabs.utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { retry, countWords } from "@voquill/utilities";
|
|
1
2
|
export const elevenlabsTestIntegration = async ({ apiKey, }) => {
|
|
2
3
|
try {
|
|
3
4
|
const response = await fetch("https://api.elevenlabs.io/v1/user", {
|
|
@@ -10,6 +11,38 @@ export const elevenlabsTestIntegration = async ({ apiKey, }) => {
|
|
|
10
11
|
return false;
|
|
11
12
|
}
|
|
12
13
|
};
|
|
14
|
+
export const elevenlabsTranscribeAudio = async ({ apiKey, blob, ext, language, }) => {
|
|
15
|
+
return retry({
|
|
16
|
+
retries: 3,
|
|
17
|
+
fn: async () => {
|
|
18
|
+
const formData = new FormData();
|
|
19
|
+
const bodyData = blob instanceof ArrayBuffer ? blob : blob.buffer;
|
|
20
|
+
const audioBlob = new Blob([bodyData], { type: `audio/${ext}` });
|
|
21
|
+
formData.append("file", audioBlob, `audio.${ext}`);
|
|
22
|
+
formData.append("model_id", "scribe_v1");
|
|
23
|
+
if (language && language !== "auto") {
|
|
24
|
+
formData.append("language_code", language);
|
|
25
|
+
}
|
|
26
|
+
const response = await fetch("https://api.elevenlabs.io/v1/speech-to-text", {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
"xi-api-key": apiKey.trim(),
|
|
30
|
+
},
|
|
31
|
+
body: formData,
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const errorText = await response.text().catch(() => "Unknown error");
|
|
35
|
+
throw new Error(`ElevenLabs API request failed with status ${response.status}: ${errorText}`);
|
|
36
|
+
}
|
|
37
|
+
const data = (await response.json());
|
|
38
|
+
const transcript = data?.text;
|
|
39
|
+
if (!transcript) {
|
|
40
|
+
throw new Error("Transcription failed: No text in ElevenLabs API response");
|
|
41
|
+
}
|
|
42
|
+
return { text: transcript, wordsUsed: countWords(transcript) };
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
13
46
|
export const convertFloat32ToBase64PCM16 = (float32Array) => {
|
|
14
47
|
const samples = Array.isArray(float32Array)
|
|
15
48
|
? float32Array
|
package/dist/gemini.utils.js
CHANGED
|
@@ -60,7 +60,7 @@ export const geminiTranscribeAudio = async ({ apiKey, model = "gemini-2.5-flash"
|
|
|
60
60
|
}
|
|
61
61
|
const base64Audio = btoa(binary);
|
|
62
62
|
let transcriptionPrompt = "Transcribe this audio accurately.";
|
|
63
|
-
if (language) {
|
|
63
|
+
if (language && language !== "auto") {
|
|
64
64
|
transcriptionPrompt += ` The audio is in ${language}.`;
|
|
65
65
|
}
|
|
66
66
|
if (prompt) {
|
package/dist/groq.utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groq.utils.d.ts","sourceRoot":"","sources":["../src/groq.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"groq.utils.d.ts","sourceRoot":"","sources":["../src/groq.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACf,MAAM,gBAAgB,CAAC;AAUxB,eAAO,MAAM,oBAAoB,yIAKvB,CAAC;AACX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB,qCAAsC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBA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AAC;AAEF,wBAAuB,cAAc,CAAC,EACpC,MAAM,EACN,KAAK,EACL,KAAK,GACN,EAAE,kBAAkB,GAAG,cAAc,CAAC,cAAc,CAAC,CAOrD"}
|
package/dist/groq.utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { countWords, retry } from "@voquill/utilities";
|
|
1
2
|
import Groq, { toFile } from "groq-sdk/index";
|
|
2
|
-
import { retry, countWords } from "@voquill/utilities";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
4
|
import { openaiCompatibleStreamChat } from "./openai.utils";
|
|
5
5
|
export const GENERATE_TEXT_MODELS = [
|
|
@@ -42,7 +42,7 @@ export const groqTranscribeAudio = async ({ apiKey, model = "whisper-large-v3-tu
|
|
|
42
42
|
file,
|
|
43
43
|
model,
|
|
44
44
|
prompt,
|
|
45
|
-
language: language
|
|
45
|
+
language: language && language !== "auto" ? language : undefined,
|
|
46
46
|
});
|
|
47
47
|
if (!response.text) {
|
|
48
48
|
throw new Error("Transcription failed");
|
|
@@ -72,9 +72,7 @@ export const groqGenerateTextResponse = async ({ apiKey, model = "meta-llama/lla
|
|
|
72
72
|
const response = await client.chat.completions.create({
|
|
73
73
|
messages,
|
|
74
74
|
model,
|
|
75
|
-
temperature: 0,
|
|
76
75
|
max_completion_tokens: 8192,
|
|
77
|
-
top_p: 1,
|
|
78
76
|
response_format: jsonResponse
|
|
79
77
|
? {
|
|
80
78
|
type: "json_schema",
|
package/dist/openai.utils.js
CHANGED
|
@@ -48,7 +48,7 @@ export const openaiTranscribeAudio = async ({ apiKey, model = "whisper-1", blob,
|
|
|
48
48
|
file,
|
|
49
49
|
model,
|
|
50
50
|
prompt,
|
|
51
|
-
language: language
|
|
51
|
+
language: language && language !== "auto" ? language : undefined,
|
|
52
52
|
});
|
|
53
53
|
if (!response.text) {
|
|
54
54
|
throw new Error("Transcription failed");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voquill/voice-ai",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Shared Groq voice transcription helpers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
17
17
|
"@azure/openai": "^2.0.0",
|
|
18
|
-
"@google/genai": "^1.
|
|
18
|
+
"@google/genai": "^1.48.0",
|
|
19
19
|
"groq-sdk": "^0.37.0",
|
|
20
|
-
"microsoft-cognitiveservices-speech-sdk": "^1.
|
|
21
|
-
"openai": "^4.
|
|
20
|
+
"microsoft-cognitiveservices-speech-sdk": "^1.49.0",
|
|
21
|
+
"openai": "^4.104.0",
|
|
22
22
|
"wavefile": "^11.0.0",
|
|
23
23
|
"zod": "^3.25.76",
|
|
24
|
-
"zod-to-json-schema": "^3.
|
|
25
|
-
"@voquill/utilities": "0.2.
|
|
26
|
-
"@voquill/types": "0.2.
|
|
24
|
+
"zod-to-json-schema": "^3.25.2",
|
|
25
|
+
"@voquill/utilities": "0.2.5",
|
|
26
|
+
"@voquill/types": "0.2.5"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "5.9.2",
|
|
30
|
-
"@voquill/typescript-config": "0.2.
|
|
30
|
+
"@voquill/typescript-config": "0.2.5"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|