mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
ftemp
This commit is contained in:
@ -13,4 +13,4 @@
|
|||||||
Dev rh
|
Dev rh
|
||||||
```bash
|
```bash
|
||||||
uvicorn main:app --reload
|
uvicorn main:app --reload
|
||||||
```
|
```
|
||||||
|
|||||||
7
main.py
7
main.py
@ -4,6 +4,7 @@ from fastapi import FastAPI, Request, status
|
|||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
from src.blackbox.blackbox_factory import BlackboxFactory
|
from src.blackbox.blackbox_factory import BlackboxFactory
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@ -11,7 +12,6 @@ blackbox_factory = BlackboxFactory()
|
|||||||
|
|
||||||
@app.post("/")
|
@app.post("/")
|
||||||
async def blackbox(blackbox_name: Union[str, None] = None, request: Request = None):
|
async def blackbox(blackbox_name: Union[str, None] = None, request: Request = None):
|
||||||
print(blackbox_name)
|
|
||||||
if not blackbox_name:
|
if not blackbox_name:
|
||||||
return await JSONResponse(content={"error": "blackbox_name is required"}, status_code=status.HTTP_400_BAD_REQUEST)
|
return await JSONResponse(content={"error": "blackbox_name is required"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
try:
|
try:
|
||||||
@ -22,4 +22,7 @@ async def blackbox(blackbox_name: Union[str, None] = None, request: Request = No
|
|||||||
|
|
||||||
@app.post("/workflows")
|
@app.post("/workflows")
|
||||||
async def workflows(reqest: Request):
|
async def workflows(reqest: Request):
|
||||||
print("workflows")
|
print("workflows")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
uvicorn.run("main:app", host="127.0.0.1", port=8000, log_level="info")
|
||||||
|
|||||||
@ -13,7 +13,9 @@ class ASR(Blackbox):
|
|||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
config = read_yaml(args[0])
|
config = read_yaml(args[0])
|
||||||
self.paraformer = RapidParaformer(config)
|
self.paraformer = RapidParaformer(config)
|
||||||
super().__init__(config)
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
return self.processing(*args, **kwargs)
|
||||||
|
|
||||||
async def processing(self, *args, **kwargs):
|
async def processing(self, *args, **kwargs):
|
||||||
data = args[0]
|
data = args[0]
|
||||||
|
|||||||
@ -12,8 +12,8 @@ class BlackboxFactory:
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.tts = TTS()
|
self.tts = TTS()
|
||||||
#self.asr = ASR("./.env.yaml")
|
self.asr = ASR(".env.yaml")
|
||||||
#self.sentiment = Sentiment()
|
self.sentiment = Sentiment()
|
||||||
#self.sum = SUM()
|
#self.sum = SUM()
|
||||||
#self.calculator = Calculator()
|
#self.calculator = Calculator()
|
||||||
#self.audio_to_text = AudioToText()
|
#self.audio_to_text = AudioToText()
|
||||||
@ -24,7 +24,6 @@ class BlackboxFactory:
|
|||||||
return self.processing(*args, **kwargs)
|
return self.processing(*args, **kwargs)
|
||||||
|
|
||||||
def create_blackbox(self, blackbox_name: str) -> Blackbox:
|
def create_blackbox(self, blackbox_name: str) -> Blackbox:
|
||||||
return self.tts
|
|
||||||
if blackbox_name == "audio_to_text":
|
if blackbox_name == "audio_to_text":
|
||||||
return self.audio_to_text
|
return self.audio_to_text
|
||||||
if blackbox_name == "text_to_audio":
|
if blackbox_name == "text_to_audio":
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import io
|
import io
|
||||||
|
from ntpath import join
|
||||||
|
|
||||||
from fastapi import Request, Response, status
|
from fastapi import Request, Response, status
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
@ -8,12 +9,7 @@ from tts.tts_service import TTService
|
|||||||
class TTS(Blackbox):
|
class TTS(Blackbox):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
config = {
|
self.tts_service = TTService("catmaid")
|
||||||
'paimon': ['resources/tts/models/paimon6k.json', 'resources/tts/models/paimon6k_390k.pth', 'character_paimon', 1],
|
|
||||||
'yunfei': ['resources/tts/models/yunfeimix2.json', 'resources/tts/models/yunfeimix2_53k.pth', 'character_yunfei', 1.1],
|
|
||||||
'catmaid': ['resources/tts/models/catmix.json', 'resources/tts/models/catmix_107k.pth', 'character_catmaid', 1.2]
|
|
||||||
}
|
|
||||||
self.tts_service = TTService(*config['catmaid'])
|
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
return self.processing(*args, **kwargs)
|
return self.processing(*args, **kwargs)
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
|
|
||||||
sys.path.append('tts/vits')
|
sys.path.append('tts/vits')
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import soundfile
|
import soundfile
|
||||||
import os
|
import os
|
||||||
os.environ["PYTORCH_JIT"] = "0"
|
os.environ["PYTORCH_JIT"] = "0"
|
||||||
@ -21,20 +19,43 @@ import logging
|
|||||||
logging.getLogger().setLevel(logging.INFO)
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
logging.basicConfig(level=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():
|
class TTService():
|
||||||
|
|
||||||
def __init__(self, cfg, model, char, speed):
|
def __init__(self, model_name="catmaid"):
|
||||||
logging.info('Initializing TTS Service for %s...' % char)
|
cfg = config[model_name]
|
||||||
self.hps = utils.get_hparams_from_file(cfg)
|
logging.info('Initializing TTS Service for %s...' % cfg["char"])
|
||||||
self.speed = speed
|
self.hps = utils.get_hparams_from_file(cfg["cfg"])
|
||||||
|
self.speed = cfg["speed"]
|
||||||
self.net_g = SynthesizerTrn(
|
self.net_g = SynthesizerTrn(
|
||||||
len(symbols),
|
len(symbols),
|
||||||
self.hps.data.filter_length // 2 + 1,
|
self.hps.data.filter_length // 2 + 1,
|
||||||
self.hps.train.segment_size // self.hps.data.hop_length,
|
self.hps.train.segment_size // self.hps.data.hop_length,
|
||||||
**self.hps.model).cpu()
|
**self.hps.model).cpu()
|
||||||
_ = self.net_g.eval()
|
_ = 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):
|
def get_text(self, text, hps):
|
||||||
text_norm = text_to_sequence(text, hps.data.text_cleaners)
|
text_norm = text_to_sequence(text, hps.data.text_cleaners)
|
||||||
|
|||||||
Reference in New Issue
Block a user