feat: 后端封装tts,可以通过配置文件切换openvoice和vits
This commit is contained in:
1 parent
e2f3decfae
commit
ce033dca2b
6 files changed
+49
-62
No files matched your search
+18
-6
@@ -1,11 +1,23 @@
|
||||
from utils.tts.openvoice_utils import TextToSpeech
|
||||
|
||||
from app.dependencies.logger import get_logger
|
||||
from config import get_config
|
||||
|
||||
logger = get_logger()
|
||||
Config = get_config()
|
||||
|
||||
from utils.tts.openvoice_utils import TextToSpeech
|
||||
openvoice_tts = TextToSpeech(use_tone_convert=True,device='cuda')
|
||||
logger.info("TTS_OPENVOICE 初始化成功")
|
||||
|
||||
from utils.tts.vits_utils import TextToSpeech
|
||||
vits_tts = TextToSpeech()
|
||||
logger.info("TTS_VITS 初始化成功")
|
||||
|
||||
|
||||
|
||||
#初始化全局tts对象
|
||||
tts = TextToSpeech(use_tone_convert=True,device='cuda')
|
||||
logger.info("TTS初始化成功")
|
||||
|
||||
def get_tts():
|
||||
return tts
|
||||
def get_tts(tts_type=Config.TTS_UTILS):
|
||||
if tts_type == "OPENVOICE":
|
||||
return openvoice_tts
|
||||
elif tts_type == "VITS":
|
||||
return vits_tts
|
||||
Reference in new issue
Block a user