@speakableio/core 1.0.65 → 1.0.67
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.native.d.mts +10 -3
- package/dist/index.native.d.ts +10 -3
- package/dist/index.native.js +32 -7
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +32 -7
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.d.mts +10 -3
- package/dist/index.web.js +32 -7
- package/dist/index.web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.mjs
CHANGED
|
@@ -2318,12 +2318,26 @@ function cleanHallucinatedTranscript(transcript) {
|
|
|
2318
2318
|
|
|
2319
2319
|
// src/utils/ai/get-transcript.ts
|
|
2320
2320
|
async function getTranscript(model, args, cleanHallucinations = true) {
|
|
2321
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2321
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2322
2322
|
const getGeminiTranscript = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "getGeminiTranscript");
|
|
2323
2323
|
const getAssemblyAITranscript = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "transcribeAssemblyAIAudio");
|
|
2324
2324
|
const getWhisper3Transcript = (_f = (_e = api).httpsCallable) == null ? void 0 : _f.call(_e, "generateGroqTranscript");
|
|
2325
2325
|
const getWhisper1Transcript = (_h = (_g = api).httpsCallable) == null ? void 0 : _h.call(_g, "transcribeAudio");
|
|
2326
|
+
const getGPT4oTranscript = (_j = (_i = api).httpsCallable) == null ? void 0 : _j.call(_i, "generateGpt4oTranscript");
|
|
2326
2327
|
console.log("Getting transcript from", model, " cleanHallucinations", cleanHallucinations);
|
|
2328
|
+
if (model === "gpt-4o") {
|
|
2329
|
+
try {
|
|
2330
|
+
const { data } = await (getGPT4oTranscript == null ? void 0 : getGPT4oTranscript({
|
|
2331
|
+
audioUrl: args.audioUrl,
|
|
2332
|
+
language: args.language,
|
|
2333
|
+
teacherPrompt: (_k = args.prompt) != null ? _k : ""
|
|
2334
|
+
}));
|
|
2335
|
+
return data;
|
|
2336
|
+
} catch (error) {
|
|
2337
|
+
console.error("Error getting transcript from GPT-4o:", error);
|
|
2338
|
+
throw error;
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2327
2341
|
if (model === "whisper-3") {
|
|
2328
2342
|
try {
|
|
2329
2343
|
const { data } = await (getWhisper3Transcript == null ? void 0 : getWhisper3Transcript({
|
|
@@ -2353,7 +2367,7 @@ async function getTranscript(model, args, cleanHallucinations = true) {
|
|
|
2353
2367
|
const { data } = await (getGeminiTranscript == null ? void 0 : getGeminiTranscript({
|
|
2354
2368
|
audioUrl: args.audioUrl,
|
|
2355
2369
|
targetLanguage: args.language,
|
|
2356
|
-
prompt: (
|
|
2370
|
+
prompt: (_l = args.prompt) != null ? _l : ""
|
|
2357
2371
|
}));
|
|
2358
2372
|
return cleanHallucinations ? cleanHallucinatedTranscript(data.transcript) : data.transcript;
|
|
2359
2373
|
} catch (error) {
|
|
@@ -2376,10 +2390,17 @@ async function getTranscript(model, args, cleanHallucinations = true) {
|
|
|
2376
2390
|
return null;
|
|
2377
2391
|
}
|
|
2378
2392
|
async function getTranscriptCycle(args) {
|
|
2379
|
-
var _a;
|
|
2380
|
-
const models =
|
|
2393
|
+
var _a, _b, _c;
|
|
2394
|
+
const models = (_b = (_a = args.options) == null ? void 0 : _a.modelOrder) != null ? _b : [
|
|
2395
|
+
"whisper",
|
|
2396
|
+
"whisper-3",
|
|
2397
|
+
"gpt-4o",
|
|
2398
|
+
"gemini",
|
|
2399
|
+
"assemblyai"
|
|
2400
|
+
];
|
|
2381
2401
|
let transcript = "";
|
|
2382
2402
|
let lastError = null;
|
|
2403
|
+
console.log("Getting transcript cycle with models", models);
|
|
2383
2404
|
for (const model of models) {
|
|
2384
2405
|
try {
|
|
2385
2406
|
console.log(
|
|
@@ -2388,9 +2409,9 @@ async function getTranscriptCycle(args) {
|
|
|
2388
2409
|
" cleanHallucinations",
|
|
2389
2410
|
args.cleanHallucinations
|
|
2390
2411
|
);
|
|
2391
|
-
const transcriptResult = await getTranscript(model, args, (
|
|
2412
|
+
const transcriptResult = await getTranscript(model, args, (_c = args.cleanHallucinations) != null ? _c : true);
|
|
2392
2413
|
const rawTranscript = transcriptResult || "";
|
|
2393
|
-
transcript =
|
|
2414
|
+
transcript = rawTranscript;
|
|
2394
2415
|
if (transcript !== "") {
|
|
2395
2416
|
console.log(`Successfully got transcript from ${model}`);
|
|
2396
2417
|
break;
|
|
@@ -3161,7 +3182,11 @@ function useSpeakableTranscript() {
|
|
|
3161
3182
|
function useSpeakableTranscriptCycle() {
|
|
3162
3183
|
const mutation = useMutation3({
|
|
3163
3184
|
mutationFn: async (args) => {
|
|
3164
|
-
return getTranscriptCycle({
|
|
3185
|
+
return getTranscriptCycle({
|
|
3186
|
+
...args,
|
|
3187
|
+
cleanHallucinations: args.cleanHallucinations,
|
|
3188
|
+
options: args.options
|
|
3189
|
+
});
|
|
3165
3190
|
},
|
|
3166
3191
|
retry: false
|
|
3167
3192
|
});
|