Merge branch 'ikechan8370:v2' into v2

This commit is contained in:
ifeif 2023-11-24 22:11:27 +08:00 committed by GitHub
commit 9723e6db17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 4289 additions and 1073 deletions

View file

@ -9,7 +9,7 @@ import crypto from 'crypto'
import child_process from 'child_process'
import { Config } from './config.js'
import path from 'path'
import { mkdirs } from './common.js'
import { mkdirs, getUin } from './common.js'
let module
try {
module = await import('oicq')
@ -41,7 +41,7 @@ if (module) {
// import { pcm2slk } from 'node-silk'
let errors = {}
async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai', ignoreEncode = false) {
let recordType = 'url'
let tmpFile = ''
if (ttsMode === 'azure') {
@ -50,6 +50,9 @@ async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
recordType = 'buffer'
tmpFile = `data/chatgpt/tts/tmp/${crypto.randomUUID()}.wav`
}
if (ignoreEncode) {
return segment.record(recordUrl)
}
let result
if (Config.ttsHD) {
result = await getPttBuffer(recordUrl, Bot.config.ffmpeg_path, false)
@ -144,7 +147,7 @@ async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
2: 3,
5: {
1: Contactable.target,
2: Bot.uin,
2: getUin(),
3: 0,
4: hash,
5: buf.length,
@ -188,7 +191,7 @@ async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
const fid = rsp[11].toBuffer()
const b = core.pb.encode({
1: 4,
2: Bot.uin,
2: getUin(),
3: fid,
4: hash,
5: hash.toString('hex') + '.amr',