mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-14 00:53:25 +00:00
ftemp
This commit is contained in:
@ -1,10 +1,8 @@
|
||||
import io
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.append('tts/vits')
|
||||
|
||||
import numpy as np
|
||||
import soundfile
|
||||
import os
|
||||
os.environ["PYTORCH_JIT"] = "0"
|
||||
@ -21,20 +19,43 @@ import logging
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
dirbaspath = __file__.split("\\")[1:-1]
|
||||
dirbaspath= "C://" + "/".join(dirbaspath)
|
||||
config = {
|
||||
'paimon': {
|
||||
'cfg': dirbaspath + '/models/paimon6k.json',
|
||||
'model': dirbaspath + '/models/paimon6k_390k.pth',
|
||||
'char': 'character_paimon',
|
||||
'speed': 1
|
||||
},
|
||||
'yunfei': {
|
||||
'cfg': dirbaspath + '/tts/models/yunfeimix2.json',
|
||||
'model': dirbaspath + '/models/yunfeimix2_53k.pth',
|
||||
'char': 'character_yunfei',
|
||||
'speed': 1.1
|
||||
},
|
||||
'catmaid': {
|
||||
'cfg': dirbaspath + '/models/catmix.json',
|
||||
'model': dirbaspath + '/models/catmix_107k.pth',
|
||||
'char': 'character_catmaid',
|
||||
'speed': 1.2
|
||||
},
|
||||
}
|
||||
|
||||
class TTService():
|
||||
|
||||
def __init__(self, cfg, model, char, speed):
|
||||
logging.info('Initializing TTS Service for %s...' % char)
|
||||
self.hps = utils.get_hparams_from_file(cfg)
|
||||
self.speed = speed
|
||||
def __init__(self, model_name="catmaid"):
|
||||
cfg = config[model_name]
|
||||
logging.info('Initializing TTS Service for %s...' % cfg["char"])
|
||||
self.hps = utils.get_hparams_from_file(cfg["cfg"])
|
||||
self.speed = cfg["speed"]
|
||||
self.net_g = SynthesizerTrn(
|
||||
len(symbols),
|
||||
self.hps.data.filter_length // 2 + 1,
|
||||
self.hps.train.segment_size // self.hps.data.hop_length,
|
||||
**self.hps.model).cpu()
|
||||
_ = self.net_g.eval()
|
||||
_ = utils.load_checkpoint(model, self.net_g, None)
|
||||
_ = utils.load_checkpoint(cfg["model"], self.net_g, None)
|
||||
|
||||
def get_text(self, text, hps):
|
||||
text_norm = text_to_sequence(text, hps.data.text_cleaners)
|
||||
|
||||
Reference in New Issue
Block a user