新增语音合成 vits-simple-api (#568)

This commit is contained in:
Mr.Raindrop 2024-03-10 11:48:58 +08:00 committed by GitHub
parent 2fef1511da
commit 579cb627e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,35 @@
from traceback import print_exc
import requests
from myutils.config import globalconfig
import time
from tts.basettsclass import TTSbase
from urllib.parse import quote
class TTS(TTSbase):
def getvoicelist(self):
responseVits = requests.get('http://127.0.0.1:23456/voice/speakers').json()
self.voicelist = []
# 获取所有模型类型,对于每个模型类型下的模型信息,将其 modelType、id、name 合成一个字符串
modelTypes = responseVits.keys()
for modelType in modelTypes:
vits_data = responseVits[modelType]
for item in vits_data:
model_info = f'{modelType}_{item["id"]}_{item["name"]}'
self.voicelist.append(model_info)
return self.voicelist
def voiceshowmap(self,voice):
return voice
def speak(self, content, rate, voice, voiceidx):
encoded_content = quote(content)
idx = int(voice.split('_')[1])
model = str.lower(voice.split('_')[0])
response = requests.get(f"http://127.0.0.1:23456/voice/{model}?text={encoded_content}&id={idx}&lang=ja&format=wav").content
fname = str(time.time())
with open('./cache/tts/'+fname+'.wav', 'wb') as ff:
ff.write(response)
return ('./cache/tts/'+fname+'.wav')

View File

@ -607,6 +607,11 @@
"voice": "",
"path": "",
"name": "VOICEVOX"
},
"vitsSimpleAPI": {
"use": false,
"voice": "",
"name": "vits-simple-api"
}
},
"hirasetting": {

View File

@ -231,6 +231,18 @@
{
"name": "VoiceRoid2_附加音源_ギャラ子",
"link": "https://github.com/HIllya51/RESOURCES/releases/download/install_free_voice_packages/galaco_44.zip"
},
{
"name": "vits-simple-api",
"link": "https://github.com/Artrajz/vits-simple-api/releases"
},
{
"name": "vits-simple-api_CPU版附模型vits-uma-genshin-honkai",
"link": "https://github.com/raindrop213/LunaTranslator-re/releases/download/v0.0.1/vits-simple-api-windows-cpu-v0.6.9_vits-uma-genshin-honkai.rar"
},
{
"name": "vits-simple-api_GPU版附模型vits-uma-genshin-honkai",
"link": "https://github.com/raindrop213/LunaTranslator-re/releases/download/v0.0.1/vits-simple-api-windows-gpu-v0.6.9_vits-uma-genshin-honkai.7z"
}
]
},