mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
Feat: 新增云转码模式选择 (#380)
* 修复后台API反代地址未能正确显示的问题 * 更新渲染页面配置 * 添加个人聊天模式配置 * 将用户数据获取改到common中 * 修复错误的渲染页面参数 * 修复bug * 添加Live2D * 修复渲染页面错误 * 修复渲染传入值 * 更新渲染 * 修复图表渲染bug * 调整live2d模型大小 * 修复live2d无法关闭问题 * 修复错误的传值 * 修复ai命名 * 更新渲染 * 添加用户独立设定 * 更新渲染配置适配个人设置 * 修复合并导致的渲染文件异常删除 * 修复用户数据缺失问题 * 修复旧版本数据缺失问题 * 修复bing参数不存在问题,兼容miao的截图 * 修复受限token重试时不被排除的问题 * 修复个人模式下结束对话的模式错误 * 更新渲染页面,将预览版转为正式版 * 修复传统渲染无法调用截图功能的问题 * 文字模式也进行一次缓存 * 更新README * Update README.md * 更新渲染 * 更新渲染页面 * 添加版本信息 * 遗漏参数 * 丢失引用 * 补充路由 * 添加云转码功能 * 判断node-silk是否正常合成 * 云转码提示 * 修复图片渲染出错 * 云转码支持发送Buffer * 添加云转码模式支持 * 更新描述 --------- Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
parent
55f060dc5f
commit
49d8dce984
13 changed files with 122 additions and 34 deletions
|
|
@ -103,6 +103,7 @@ const defaultConfig = {
|
|||
slackClaudeGlobalPreset: '',
|
||||
slackClaudeSpecifiedChannel: '',
|
||||
cloudTranscode: '',
|
||||
cloudMode: 'url',
|
||||
version: 'v2.5.6'
|
||||
}
|
||||
const _path = process.cwd()
|
||||
|
|
|
|||
|
|
@ -35,27 +35,56 @@ async function uploadRecord (recordUrl) {
|
|||
if (pcm2slk) {
|
||||
result = await getPttBuffer(recordUrl, Bot.config.ffmpeg_path)
|
||||
} else if (Config.cloudTranscode) {
|
||||
const resultOption = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({recordUrl: recordUrl})
|
||||
}
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/audio`, resultOption)
|
||||
if (!resultres.ok) {
|
||||
try {
|
||||
if (Config.cloudMode === 'buffer' || Config.cloudMode === 'file') {
|
||||
let response = await fetch(recordUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 12; MI 9 Build/SKQ1.211230.001)'
|
||||
},
|
||||
})
|
||||
if (Config.cloudMode === 'file') {
|
||||
const file = await response.blob()
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/audio`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
result = await resultres.json()
|
||||
} else {
|
||||
const buf = Buffer.from(await response.arrayBuffer())
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/audio`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({recordBuffer: buf})
|
||||
})
|
||||
result = await resultres.json()
|
||||
}
|
||||
} else {
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/audio`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({recordUrl: recordUrl})
|
||||
})
|
||||
result = await resultres.json()
|
||||
}
|
||||
if (result.error) {
|
||||
logger.error('云转码API报错:' + result.error)
|
||||
return false
|
||||
}
|
||||
result.buffer = Buffer.from(result.buffer.data)
|
||||
} catch (err) {
|
||||
logger.error('云转码API报错:' + err)
|
||||
return false
|
||||
}
|
||||
result = await resultres.json()
|
||||
if (result.error) {
|
||||
logger.error('云转码API报错:' + result.error)
|
||||
return false
|
||||
}
|
||||
result.buffer = Buffer.from(result.buffer.data)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!result.buffer) {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue