@speakableio/core 1.0.63 → 1.0.65
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 +3 -0
- package/dist/index.native.d.ts +3 -0
- package/dist/index.native.js +24 -13
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +24 -13
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.d.mts +3 -0
- package/dist/index.web.js +24 -13
- package/dist/index.web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.mjs
CHANGED
|
@@ -1531,7 +1531,7 @@ function useSubmitAssignmentScore({
|
|
|
1531
1531
|
status,
|
|
1532
1532
|
studentName
|
|
1533
1533
|
});
|
|
1534
|
-
if (assignment.courseWorkId != null && !assignment.isAssessment
|
|
1534
|
+
if (assignment.courseWorkId != null && !assignment.isAssessment) {
|
|
1535
1535
|
await submitAssignmentToGoogleClassroom({
|
|
1536
1536
|
assignment,
|
|
1537
1537
|
scores
|
|
@@ -2217,6 +2217,10 @@ function detectTranscriptHallucination(transcript) {
|
|
|
2217
2217
|
return false;
|
|
2218
2218
|
}
|
|
2219
2219
|
const text = transcript.trim();
|
|
2220
|
+
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
|
2221
|
+
if (text.length < 120 || wordCount < 20) {
|
|
2222
|
+
return false;
|
|
2223
|
+
}
|
|
2220
2224
|
const shortRepeats = detectShortRepeats(text);
|
|
2221
2225
|
if (shortRepeats) return true;
|
|
2222
2226
|
const phraseRepeats = detectPhraseRepeats(text);
|
|
@@ -2232,14 +2236,14 @@ function detectShortRepeats(text) {
|
|
|
2232
2236
|
for (let i = 1; i < words.length; i++) {
|
|
2233
2237
|
if (words[i] === words[i - 1]) {
|
|
2234
2238
|
repeatCount++;
|
|
2235
|
-
if (repeatCount >=
|
|
2239
|
+
if (repeatCount >= 4) return true;
|
|
2236
2240
|
} else {
|
|
2237
2241
|
repeatCount = 1;
|
|
2238
2242
|
}
|
|
2239
2243
|
}
|
|
2240
2244
|
const uniqueWords = new Set(words);
|
|
2241
2245
|
const repetitionRatio = words.length / uniqueWords.size;
|
|
2242
|
-
if (words.length >=
|
|
2246
|
+
if (words.length >= 12 && uniqueWords.size <= 2 && repetitionRatio >= 5) {
|
|
2243
2247
|
return true;
|
|
2244
2248
|
}
|
|
2245
2249
|
return false;
|
|
@@ -2256,12 +2260,12 @@ function detectPhraseRepeats(text) {
|
|
|
2256
2260
|
break;
|
|
2257
2261
|
}
|
|
2258
2262
|
}
|
|
2259
|
-
if (consecutiveRepeats >=
|
|
2263
|
+
if (consecutiveRepeats >= 3) {
|
|
2260
2264
|
return true;
|
|
2261
2265
|
}
|
|
2262
2266
|
}
|
|
2263
2267
|
const uniqueSentences = new Set(sentences);
|
|
2264
|
-
if (sentences.length >=
|
|
2268
|
+
if (sentences.length >= 4 && uniqueSentences.size === 1) {
|
|
2265
2269
|
return true;
|
|
2266
2270
|
}
|
|
2267
2271
|
return false;
|
|
@@ -2278,7 +2282,7 @@ function isSimilarSentence(s1, s2) {
|
|
|
2278
2282
|
const set2 = new Set(words2);
|
|
2279
2283
|
const intersection = new Set([...set1].filter((w) => set2.has(w)));
|
|
2280
2284
|
const similarity = intersection.size * 2 / (set1.size + set2.size);
|
|
2281
|
-
return similarity >= 0.
|
|
2285
|
+
return similarity >= 0.9;
|
|
2282
2286
|
}
|
|
2283
2287
|
function detectCyclicPattern(text) {
|
|
2284
2288
|
const normalized = text.toLowerCase().replace(/\s+/g, " ").trim();
|
|
@@ -2298,7 +2302,7 @@ function detectCyclicPattern(text) {
|
|
|
2298
2302
|
break;
|
|
2299
2303
|
}
|
|
2300
2304
|
}
|
|
2301
|
-
if (matchCount >=
|
|
2305
|
+
if (matchCount >= 4) {
|
|
2302
2306
|
return true;
|
|
2303
2307
|
}
|
|
2304
2308
|
}
|
|
@@ -2319,7 +2323,7 @@ async function getTranscript(model, args, cleanHallucinations = true) {
|
|
|
2319
2323
|
const getAssemblyAITranscript = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "transcribeAssemblyAIAudio");
|
|
2320
2324
|
const getWhisper3Transcript = (_f = (_e = api).httpsCallable) == null ? void 0 : _f.call(_e, "generateGroqTranscript");
|
|
2321
2325
|
const getWhisper1Transcript = (_h = (_g = api).httpsCallable) == null ? void 0 : _h.call(_g, "transcribeAudio");
|
|
2322
|
-
console.log("Getting transcript from", model);
|
|
2326
|
+
console.log("Getting transcript from", model, " cleanHallucinations", cleanHallucinations);
|
|
2323
2327
|
if (model === "whisper-3") {
|
|
2324
2328
|
try {
|
|
2325
2329
|
const { data } = await (getWhisper3Transcript == null ? void 0 : getWhisper3Transcript({
|
|
@@ -2372,13 +2376,19 @@ async function getTranscript(model, args, cleanHallucinations = true) {
|
|
|
2372
2376
|
return null;
|
|
2373
2377
|
}
|
|
2374
2378
|
async function getTranscriptCycle(args) {
|
|
2379
|
+
var _a;
|
|
2375
2380
|
const models = ["whisper-3", "whisper", "gemini", "assemblyai"];
|
|
2376
2381
|
let transcript = "";
|
|
2377
2382
|
let lastError = null;
|
|
2378
2383
|
for (const model of models) {
|
|
2379
2384
|
try {
|
|
2380
|
-
console.log(
|
|
2381
|
-
|
|
2385
|
+
console.log(
|
|
2386
|
+
"Getting transcript from",
|
|
2387
|
+
model,
|
|
2388
|
+
" cleanHallucinations",
|
|
2389
|
+
args.cleanHallucinations
|
|
2390
|
+
);
|
|
2391
|
+
const transcriptResult = await getTranscript(model, args, (_a = args.cleanHallucinations) != null ? _a : true);
|
|
2382
2392
|
const rawTranscript = transcriptResult || "";
|
|
2383
2393
|
transcript = cleanHallucinatedTranscript(rawTranscript);
|
|
2384
2394
|
if (transcript !== "") {
|
|
@@ -3137,9 +3147,10 @@ function useSpeakableTranscript() {
|
|
|
3137
3147
|
model,
|
|
3138
3148
|
audioUrl,
|
|
3139
3149
|
language,
|
|
3140
|
-
prompt
|
|
3150
|
+
prompt,
|
|
3151
|
+
cleanHallucinations = true
|
|
3141
3152
|
}) => {
|
|
3142
|
-
return getTranscript(model, { audioUrl, language, prompt });
|
|
3153
|
+
return getTranscript(model, { audioUrl, language, prompt }, cleanHallucinations);
|
|
3143
3154
|
},
|
|
3144
3155
|
retry: false
|
|
3145
3156
|
});
|
|
@@ -3150,7 +3161,7 @@ function useSpeakableTranscript() {
|
|
|
3150
3161
|
function useSpeakableTranscriptCycle() {
|
|
3151
3162
|
const mutation = useMutation3({
|
|
3152
3163
|
mutationFn: async (args) => {
|
|
3153
|
-
return getTranscriptCycle(args);
|
|
3164
|
+
return getTranscriptCycle({ ...args, cleanHallucinations: args.cleanHallucinations });
|
|
3154
3165
|
},
|
|
3155
3166
|
retry: false
|
|
3156
3167
|
});
|