utilitas 1999.1.47 → 1999.1.48
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 +7 -0
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +8 -1
- package/lib/bot.mjs +22 -9
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -1566,6 +1566,12 @@ export {
|
|
|
1566
1566
|
listGptFineTuningEvents,
|
|
1567
1567
|
listGptFineTuningJobs,
|
|
1568
1568
|
listOpenAIModels,
|
|
1569
|
+
m4a,
|
|
1570
|
+
mp3,
|
|
1571
|
+
mp4,
|
|
1572
|
+
mpeg,
|
|
1573
|
+
mpega,
|
|
1574
|
+
mpga,
|
|
1569
1575
|
ogg,
|
|
1570
1576
|
prompt,
|
|
1571
1577
|
promptAnthropic,
|
|
@@ -1578,5 +1584,6 @@ export {
|
|
|
1578
1584
|
trimPrompt,
|
|
1579
1585
|
uploadFile,
|
|
1580
1586
|
uploadFileForFineTuning,
|
|
1581
|
-
wav
|
|
1587
|
+
wav,
|
|
1588
|
+
webm,
|
|
1582
1589
|
};
|
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