@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.
@@ -1690,7 +1690,8 @@ declare function SpeakableProvider({ user, children, queryClient, permissions, f
1690
1690
  }): react_jsx_runtime.JSX.Element | null;
1691
1691
  declare function useSpeakableApi(): FsContext;
1692
1692
 
1693
- declare function getTranscript(model: 'gemini' | 'assemblyai' | 'whisper' | 'whisper-3', args: {
1693
+ type TranscriptModel = 'gemini' | 'assemblyai' | 'whisper' | 'whisper-3' | 'gpt-4o';
1694
+ declare function getTranscript(model: TranscriptModel, args: {
1694
1695
  language: string;
1695
1696
  audioUrl: string;
1696
1697
  prompt?: string;
@@ -1700,6 +1701,9 @@ declare function getTranscriptCycle(args: {
1700
1701
  language: string;
1701
1702
  prompt?: string;
1702
1703
  cleanHallucinations?: boolean;
1704
+ options?: {
1705
+ modelOrder?: TranscriptModel[];
1706
+ };
1703
1707
  }): Promise<{
1704
1708
  transcript: string;
1705
1709
  success: boolean;
@@ -2968,7 +2972,7 @@ declare const useOrganizationAccess: () => {
2968
2972
 
2969
2973
  declare function useSpeakableTranscript(): {
2970
2974
  mutation: _tanstack_react_query.UseMutationResult<string | null, Error, {
2971
- model: "gemini" | "assemblyai" | "whisper" | "whisper-3";
2975
+ model: TranscriptModel;
2972
2976
  audioUrl: string;
2973
2977
  language: string;
2974
2978
  prompt?: string;
@@ -2984,6 +2988,9 @@ declare function useSpeakableTranscriptCycle(): {
2984
2988
  language: string;
2985
2989
  prompt: string;
2986
2990
  cleanHallucinations?: boolean;
2991
+ options?: {
2992
+ modelOrder?: TranscriptModel[];
2993
+ };
2987
2994
  }, unknown>;
2988
2995
  };
2989
2996
 
@@ -3566,4 +3573,4 @@ declare const createFsClientWeb: ({ db, httpsCallable, logEvent }: FsClientParam
3566
3573
  };
3567
3574
  };
3568
3575
 
3569
- export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, CONVERSATION_PAGE_ACTIVITY_TYPES, ConversationPageMode, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type MediaPageActivity, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_ANALYTICS, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsConversationPage, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientWeb as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPageMediaData, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getSingleMediaPageData, getTotalCompletedCards, getTranscript, getTranscriptCycle, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useClearScoreV2, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSpeakableTranscript, useSpeakableTranscriptCycle, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
3576
+ export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, CONVERSATION_PAGE_ACTIVITY_TYPES, ConversationPageMode, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type MediaPageActivity, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_ANALYTICS, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, type TranscriptModel, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsConversationPage, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientWeb as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPageMediaData, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getSingleMediaPageData, getTotalCompletedCards, getTranscript, getTranscriptCycle, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useClearScoreV2, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSpeakableTranscript, useSpeakableTranscriptCycle, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
package/dist/index.web.js 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: (_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,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 = ["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
+ "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, (_a = args.cleanHallucinations) != null ? _a : true);
2412
+ const transcriptResult = await getTranscript(model, args, (_c = args.cleanHallucinations) != null ? _c : true);
2392
2413
  const rawTranscript = transcriptResult || "";
2393
- transcript = cleanHallucinatedTranscript(rawTranscript);
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({ ...args, cleanHallucinations: args.cleanHallucinations });
3185
+ return getTranscriptCycle({
3186
+ ...args,
3187
+ cleanHallucinations: args.cleanHallucinations,
3188
+ options: args.options
3189
+ });
3165
3190
  },
3166
3191
  retry: false
3167
3192
  });