mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
fix: 优化tts对配置的处理
This commit is contained in:
parent
d3cea768f7
commit
5cbd2cad15
1 changed files with 7 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { Config } from './config.js'
|
import { Config } from './config.js'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import random from 'random'
|
import _ from 'lodash'
|
||||||
let proxy
|
let proxy
|
||||||
if (Config.proxy) {
|
if (Config.proxy) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -24,7 +24,6 @@ const newFetch = (url, options = {}) => {
|
||||||
|
|
||||||
return fetch(url, mergedOptions)
|
return fetch(url, mergedOptions)
|
||||||
}
|
}
|
||||||
const space = Config.ttsSpace
|
|
||||||
|
|
||||||
function randomNum (minNum, maxNum) {
|
function randomNum (minNum, maxNum) {
|
||||||
switch (arguments.length) {
|
switch (arguments.length) {
|
||||||
|
|
@ -48,6 +47,12 @@ export async function generateAudio (text, speaker = '随机', language = '中
|
||||||
noiseScale, noiseScaleW, lengthScale
|
noiseScale, noiseScaleW, lengthScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
let space = Config.ttsSpace
|
||||||
|
if (space.endsWith('api/generate')) {
|
||||||
|
let trimmedSpace = _.trimEnd(space, '/api/generate')
|
||||||
|
logger.warn(`vits api 当前为${space},已校正为${trimmedSpace}`)
|
||||||
|
space = trimmedSpace
|
||||||
|
}
|
||||||
logger.info(`正在使用接口${space}/api/generate`)
|
logger.info(`正在使用接口${space}/api/generate`)
|
||||||
let response = await newFetch(`${space}/api/generate`, {
|
let response = await newFetch(`${space}/api/generate`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue