diff --git a/guoba.support.js b/guoba.support.js index 99034b7..231195f 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -344,6 +344,12 @@ export function supportGuoba () { bottomHelpMessage: '前往duplicate空间https://huggingface.co/spaces/ikechan8370/vits-uma-genshin-honkai后查看api地址', component: 'Input' }, + { + field: 'huggingFaceReverseProxy', + label: '语音转换huggingface反代', + bottomHelpMessage: '没有就空着', + component: 'Input' + }, { field: 'noiseScale', label: 'noiseScale', diff --git a/utils/config.js b/utils/config.js index 80c549a..ffd42d5 100644 --- a/utils/config.js +++ b/utils/config.js @@ -51,11 +51,13 @@ const defaultConfig = { defaultTimeoutMs: 120000, chromeTimeoutMS: 120000, ttsSpace: '', + // https://114514.201666.xyz + huggingFaceReverseProxy: '', noiseScale: 0.6, noiseScaleW: 0.668, lengthScale: 1.2, initiativeChatGroups: [], - version: 'v2.1.3' + version: 'v2.1.4' } const _path = process.cwd() let config = {} diff --git a/utils/tts.js b/utils/tts.js index a22ce4a..a9c4aa5 100644 --- a/utils/tts.js +++ b/utils/tts.js @@ -58,8 +58,12 @@ export async function generateAudio (text, speaker = '随机', language = '中 logger.warn(`vits api 当前为${space},已校正为${trimmedSpace}`) space = trimmedSpace } - logger.info(`正在使用接口${space}/api/generate`) - let response = await newFetch(`${space}/api/generate`, { + let url = `${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', body: JSON.stringify(body), headers: { @@ -79,6 +83,13 @@ export async function generateAudio (text, speaker = '随机', language = '中 let [message, audioInfo, take] = json?.data logger.info(message, take) 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 } catch (err) { logger.error('生成语音api发生错误,请检查是否配置了正确的api,且仓库是否开放为public', response.status)