xvai-loi 0.1.87 → 0.1.88
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/co.txt +1 -1
- package/package.json +1 -1
- package/xvai-loi.js +19 -6
package/co.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
xvaiLoi120538
|
package/package.json
CHANGED
package/xvai-loi.js
CHANGED
|
@@ -16029,7 +16029,12 @@ var MontagePanel = ({ project, onUpdate, onExport }) => {
|
|
|
16029
16029
|
var parse2 = (text2) => {
|
|
16030
16030
|
const a = text2.indexOf("{"), b = text2.lastIndexOf("}");
|
|
16031
16031
|
if (a < 0 || b < a) throw new Error("AI ch\u01B0a tr\u1EA3 d\u1EEF li\u1EC7u l\u1EDDi n\xF3i.");
|
|
16032
|
-
|
|
16032
|
+
const t = text2.slice(a, b + 1);
|
|
16033
|
+
try {
|
|
16034
|
+
return JSON.parse(t);
|
|
16035
|
+
} catch (e) {
|
|
16036
|
+
return JSON.parse(t.replace(/([{,]\s*)([A-Za-z_][A-Za-z0-9_]*)\s*:/g, '$1"$2":').replace(/,\s*([}\]])/g, "$1"));
|
|
16037
|
+
}
|
|
16033
16038
|
};
|
|
16034
16039
|
async function analyzeSpeech(project, scene, item, request, onProgress, onCache, cancel, templateMode = false, dense = false, boNhan = false) {
|
|
16035
16040
|
const active = () => {
|
|
@@ -16060,10 +16065,18 @@ async function analyzeSpeech(project, scene, item, request, onProgress, onCache,
|
|
|
16060
16065
|
let part = cached[n];
|
|
16061
16066
|
if (!part) {
|
|
16062
16067
|
const prompt = "Ch\xE9p CH\xCDNH X\xC1C ti\u1EBFng Vi\u1EC7t nghe \u0111\u01B0\u1EE3c, kh\xF4ng vi\u1EBFt l\u1EA1i, kh\xF4ng th\xEAm l\u1EDDi t\u1EEB ki\u1EBFn th\u1EE9c. Ch\u1ED7 im l\u1EB7ng/nh\u1EA1c kh\xF4ng c\xF3 l\u1EDDi tr\u1EA3 r\u1ED7ng. Tr\u1EA3 JSON {words:[{t0,t1,text}],unclear:[]}. M\u1ED7i text l\xE0 m\u1ED9t ti\u1EBFng/t\u1EEB nghe \u0111\u01B0\u1EE3c, timestamp gi\xE2y t\xEDnh t\u1EEB \u0111\u1EA7u t\u1EC7p \xE2m thanh n\xE0y, t\u0103ng d\u1EA7n, kh\xF4ng ch\u1ED3ng, trong 0.." + (b - a).toFixed(3) + ". Kh\xF4ng g\u1ED9p c\xE2u v\xE0o m\u1ED9t t\u1EEB. Gi\u1EEF t\xEAn ri\xEAng v\xE0 d\u1EA5u ti\u1EBFng Vi\u1EC7t. N\u1EBFu kh\xF4ng ch\u1EAFc ghi unclear, kh\xF4ng b\u1ECBa.";
|
|
16063
|
-
|
|
16064
|
-
|
|
16065
|
-
|
|
16066
|
-
|
|
16068
|
+
let parsed = null;
|
|
16069
|
+
for (let lan2 = 0; lan2 < 2 && !parsed; lan2++) {
|
|
16070
|
+
const result = await Flow.generate.text(prompt, { audios: [{ base64: wav64(pcm.subarray(Math.round(a * 16e3), Math.round(b * 16e3))), mimeType: "audio/wav" }], thinkingLevel: "medium" });
|
|
16071
|
+
calls++;
|
|
16072
|
+
active();
|
|
16073
|
+
try {
|
|
16074
|
+
parsed = parse2(result.text);
|
|
16075
|
+
} catch (e) {
|
|
16076
|
+
if (lan2) throw e;
|
|
16077
|
+
}
|
|
16078
|
+
}
|
|
16079
|
+
const valid2 = validateWords(parsed.words, 0, b - a);
|
|
16067
16080
|
part = { start, end, words: valid2.map((w) => ({ ...w, t0: w.t0 + a, t1: w.t1 + a })).filter((w) => (w.t0 + w.t1) / 2 >= start && (w.t0 + w.t1) / 2 < end), unclear: Array.isArray(parsed.unclear) ? parsed.unclear : [] };
|
|
16068
16081
|
}
|
|
16069
16082
|
parts.push(part);
|
|
@@ -21009,7 +21022,7 @@ function datCauLenh(a) {
|
|
|
21009
21022
|
on2 = true;
|
|
21010
21023
|
window.addEventListener("message", async (ev) => {
|
|
21011
21024
|
const d = ev.data;
|
|
21012
|
-
if (!d || d.
|
|
21025
|
+
if (!d || d.xvaiLoi120538 !== true) return;
|
|
21013
21026
|
const o = String(ev.origin || "");
|
|
21014
21027
|
if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
|
|
21015
21028
|
const tra = (kq) => {
|