utilitas 1999.1.47 → 1999.1.49
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/README.md +8 -0
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +9 -1
- package/lib/bot.mjs +22 -9
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -1529,6 +1529,7 @@ export default init;
|
|
|
1529
1529
|
export {
|
|
1530
1530
|
_NEED,
|
|
1531
1531
|
_NO_RENDER,
|
|
1532
|
+
ATTACHMENTS,
|
|
1532
1533
|
CLOUD_37_SONNET,
|
|
1533
1534
|
CODE_INTERPRETER,
|
|
1534
1535
|
DEEPSEEK_R1,
|
|
@@ -1566,6 +1567,12 @@ export {
|
|
|
1566
1567
|
listGptFineTuningEvents,
|
|
1567
1568
|
listGptFineTuningJobs,
|
|
1568
1569
|
listOpenAIModels,
|
|
1570
|
+
m4a,
|
|
1571
|
+
mp3,
|
|
1572
|
+
mp4,
|
|
1573
|
+
mpeg,
|
|
1574
|
+
mpega,
|
|
1575
|
+
mpga,
|
|
1569
1576
|
ogg,
|
|
1570
1577
|
prompt,
|
|
1571
1578
|
promptAnthropic,
|
|
@@ -1578,5 +1585,6 @@ export {
|
|
|
1578
1585
|
trimPrompt,
|
|
1579
1586
|
uploadFile,
|
|
1580
1587
|
uploadFileForFineTuning,
|
|
1581
|
-
wav
|
|
1588
|
+
wav,
|
|
1589
|
+
webm,
|
|
1582
1590
|
};
|
package/lib/bot.mjs
CHANGED
|
@@ -7,10 +7,13 @@ import {
|
|
|
7
7
|
throwError, timeout, trim, which,
|
|
8
8
|
} from './utilitas.mjs';
|
|
9
9
|
|
|
10
|
+
import {
|
|
11
|
+
jpeg, ogg, wav, mp3, mpega, mp4, mpeg, mpga, m4a, webm,
|
|
12
|
+
} from './alan.mjs';
|
|
13
|
+
|
|
10
14
|
import { readdirSync } from 'fs';
|
|
11
15
|
import { parseArgs as _parseArgs } from 'node:util';
|
|
12
16
|
import { basename, join } from 'path';
|
|
13
|
-
import { jpeg, ogg, wav } from './alan.mjs';
|
|
14
17
|
import { isPrimary, on, report } from './callosum.mjs';
|
|
15
18
|
import { cleanSql, encodeVector, MYSQL, POSTGRESQL } from './dbio.mjs';
|
|
16
19
|
import { convertAudioTo16kNanoPcmWave } from './media.mjs';
|
|
@@ -511,8 +514,10 @@ const subconscious = [{
|
|
|
511
514
|
&& (ctx.chatType = MENTION);
|
|
512
515
|
(((ctx.txt || ctx.m.voice || ctx.m.poll || ctx.m.data || ctx.m.document
|
|
513
516
|
|| ctx.m.photo || ctx.m.sticker || ctx.m.video_note || ctx.m.video
|
|
514
|
-
|| ctx.m.
|
|
515
|
-
|
|
517
|
+
|| ctx.m.audio || ctx.m.location || ctx.m.venue || ctx.m.contact
|
|
518
|
+
) && ctx.messageId)
|
|
519
|
+
|| (ctx.m.new_chat_member || ctx.m.left_chat_member))
|
|
520
|
+
&& await next();
|
|
516
521
|
await sessionSet(ctx.chatId);
|
|
517
522
|
},
|
|
518
523
|
}, {
|
|
@@ -647,15 +652,23 @@ const subconscious = [{
|
|
|
647
652
|
},
|
|
648
653
|
}, {
|
|
649
654
|
run: true, priority: -8910, name: 'speech-to-text', func: async (ctx, next) => {
|
|
650
|
-
|
|
655
|
+
const audio = ctx.m.voice || ctx.m.audio;
|
|
656
|
+
if (ctx._.speech?.stt && audio) {
|
|
651
657
|
await ctx.ok(EMOJI_SPEECH);
|
|
652
658
|
try {
|
|
653
|
-
const url = await getFileUrl(
|
|
654
|
-
|
|
659
|
+
const url = await getFileUrl(audio.file_id);
|
|
660
|
+
let file = await getFile(audio.file_id, BUFFER_ENCODE);
|
|
655
661
|
const analyze = async () => {
|
|
656
|
-
const resp = await ignoreErrFunc(
|
|
657
|
-
|
|
658
|
-
|
|
662
|
+
const resp = await ignoreErrFunc(async () => {
|
|
663
|
+
[
|
|
664
|
+
mp3, mpega, mp4, mpeg, mpga, m4a, wav, webm, ogg
|
|
665
|
+
].includes(audio.mime_type) || (
|
|
666
|
+
file = await convertAudioTo16kNanoPcmWave(
|
|
667
|
+
file, { input: BUFFER, expected: BUFFER }
|
|
668
|
+
)
|
|
669
|
+
);
|
|
670
|
+
return await ctx._.speech?.stt(file);
|
|
671
|
+
}, logOptions) || ' ';
|
|
659
672
|
log(`STT: '${resp}'`);
|
|
660
673
|
ctx.collect(resp);
|
|
661
674
|
};
|
package/lib/manifest.mjs
CHANGED