@speakableio/core 1.0.65 → 1.0.66

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.
@@ -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: (_i = args.prompt) != null ? _i : ""
2370
+ prompt: (_l = args.prompt) != null ? _l : ""
2357
2371
  }));
2358
2372
  return cleanHallucinations ? cleanHallucinatedTranscript(data.transcript) : data.transcript;
2359
2373
  } catch (error) {
@@ -2376,8 +2390,14 @@ 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 = ["whisper-3", "whisper", "gemini", "assemblyai"];
2393
+ var _a, _b, _c;
2394
+ const models = (_b = (_a = args.options) == null ? void 0 : _a.modelOrder) != null ? _b : [
2395
+ "gpt-4o",
2396
+ "whisper",
2397
+ "whisper-3",
2398
+ "gemini",
2399
+ "assemblyai"
2400
+ ];
2381
2401
  let transcript = "";
2382
2402
  let lastError = null;
2383
2403
  for (const model of models) {
@@ -2388,9 +2408,9 @@ async function getTranscriptCycle(args) {
2388
2408
  " cleanHallucinations",
2389
2409
  args.cleanHallucinations
2390
2410
  );
2391
- const transcriptResult = await getTranscript(model, args, (_a = args.cleanHallucinations) != null ? _a : true);
2411
+ const transcriptResult = await getTranscript(model, args, (_c = args.cleanHallucinations) != null ? _c : true);
2392
2412
  const rawTranscript = transcriptResult || "";
2393
- transcript = cleanHallucinatedTranscript(rawTranscript);
2413
+ transcript = rawTranscript;
2394
2414
  if (transcript !== "") {
2395
2415
  console.log(`Successfully got transcript from ${model}`);
2396
2416
  break;
@@ -3161,7 +3181,11 @@ function useSpeakableTranscript() {
3161
3181
  function useSpeakableTranscriptCycle() {
3162
3182
  const mutation = useMutation3({
3163
3183
  mutationFn: async (args) => {
3164
- return getTranscriptCycle({ ...args, cleanHallucinations: args.cleanHallucinations });
3184
+ return getTranscriptCycle({
3185
+ ...args,
3186
+ cleanHallucinations: args.cleanHallucinations,
3187
+ options: args.options
3188
+ });
3165
3189
  },
3166
3190
  retry: false
3167
3191
  });