mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 支持huggingface的反代
This commit is contained in:
parent
85809385c8
commit
f0c43ca3cb
3 changed files with 22 additions and 3 deletions
|
|
@ -344,6 +344,12 @@ export function supportGuoba () {
|
||||||
bottomHelpMessage: '前往duplicate空间https://huggingface.co/spaces/ikechan8370/vits-uma-genshin-honkai后查看api地址',
|
bottomHelpMessage: '前往duplicate空间https://huggingface.co/spaces/ikechan8370/vits-uma-genshin-honkai后查看api地址',
|
||||||
component: 'Input'
|
component: 'Input'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'huggingFaceReverseProxy',
|
||||||
|
label: '语音转换huggingface反代',
|
||||||
|
bottomHelpMessage: '没有就空着',
|
||||||
|
component: 'Input'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'noiseScale',
|
field: 'noiseScale',
|
||||||
label: 'noiseScale',
|
label: 'noiseScale',
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,13 @@ const defaultConfig = {
|
||||||
defaultTimeoutMs: 120000,
|
defaultTimeoutMs: 120000,
|
||||||
chromeTimeoutMS: 120000,
|
chromeTimeoutMS: 120000,
|
||||||
ttsSpace: '',
|
ttsSpace: '',
|
||||||
|
// https://114514.201666.xyz
|
||||||
|
huggingFaceReverseProxy: '',
|
||||||
noiseScale: 0.6,
|
noiseScale: 0.6,
|
||||||
noiseScaleW: 0.668,
|
noiseScaleW: 0.668,
|
||||||
lengthScale: 1.2,
|
lengthScale: 1.2,
|
||||||
initiativeChatGroups: [],
|
initiativeChatGroups: [],
|
||||||
version: 'v2.1.3'
|
version: 'v2.1.4'
|
||||||
}
|
}
|
||||||
const _path = process.cwd()
|
const _path = process.cwd()
|
||||||
let config = {}
|
let config = {}
|
||||||
|
|
|
||||||
15
utils/tts.js
15
utils/tts.js
|
|
@ -58,8 +58,12 @@ export async function generateAudio (text, speaker = '随机', language = '中
|
||||||
logger.warn(`vits api 当前为${space},已校正为${trimmedSpace}`)
|
logger.warn(`vits api 当前为${space},已校正为${trimmedSpace}`)
|
||||||
space = trimmedSpace
|
space = trimmedSpace
|
||||||
}
|
}
|
||||||
logger.info(`正在使用接口${space}/api/generate`)
|
let url = `${space}/api/generate`
|
||||||
let response = await newFetch(`${space}/api/generate`, {
|
if (Config.huggingFaceReverseProxy) {
|
||||||
|
url = `${Config.huggingFaceReverseProxy}/api/generate?space=${_.trimStart(space, 'https://')}`
|
||||||
|
}
|
||||||
|
logger.info(`正在使用接口${url}`)
|
||||||
|
let response = await newFetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -79,6 +83,13 @@ export async function generateAudio (text, speaker = '随机', language = '中
|
||||||
let [message, audioInfo, take] = json?.data
|
let [message, audioInfo, take] = json?.data
|
||||||
logger.info(message, take)
|
logger.info(message, take)
|
||||||
let audioLink = `${space}/file=${audioInfo.name}`
|
let audioLink = `${space}/file=${audioInfo.name}`
|
||||||
|
if (Config.huggingFaceReverseProxy) {
|
||||||
|
if (Config.debug) {
|
||||||
|
logger.info('使用huggingface加速反代下载生成音频' + Config.huggingFaceReverseProxy)
|
||||||
|
}
|
||||||
|
let spaceHost = _.trimStart(space, 'https://')
|
||||||
|
audioLink = `${Config.huggingFaceReverseProxy}/file=${audioInfo.name}?space=${spaceHost}`
|
||||||
|
}
|
||||||
return audioLink
|
return audioLink
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('生成语音api发生错误,请检查是否配置了正确的api,且仓库是否开放为public', response.status)
|
logger.error('生成语音api发生错误,请检查是否配置了正确的api,且仓库是否开放为public', response.status)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue