This commit is contained in:
superobk
2024-03-27 16:20:12 +08:00
parent 229501515a
commit 2a0c0e0477
86 changed files with 16 additions and 11 deletions

View File

@ -3,14 +3,14 @@ from typing import Any, Coroutine
from fastapi import Request, Response, status
from fastapi.responses import JSONResponse
from sentiment_engine.sentiment_engine import SentimentEngine
from ..sentiment_engine.sentiment_engine import SentimentEngine
from .blackbox import Blackbox
class Sentiment(Blackbox):
def __init__(self) -> None:
self.engine = SentimentEngine('resources/sentiment_engine/models/paimon_sentiment.onnx')
self.engine = SentimentEngine()
def __call__(self, *args, **kwargs):
return self.processing(*args, **kwargs)

View File

@ -4,7 +4,7 @@ from ntpath import join
from fastapi import Request, Response, status
from fastapi.responses import JSONResponse
from .blackbox import Blackbox
from tts.tts_service import TTService
from ..tts.tts_service import TTService
class TTS(Blackbox):

View File

@ -4,12 +4,17 @@ import onnxruntime
from transformers import BertTokenizer
import numpy as np
dirabspath = __file__.split("\\")[1:-1]
dirabspath= "C://" + "/".join(dirabspath)
default_path = dirabspath + "/models/paimon_sentiment.onnx"
class SentimentEngine():
def __init__(self, model_path="resources/sentiment_engine/models/paimon_sentiment.onnx"):
def __init__(self):
logging.info('Initializing Sentiment Engine...')
onnx_model_path = model_path
onnx_model_path = default_path
self.ort_session = onnxruntime.InferenceSession(onnx_model_path, providers=['CPUExecutionProvider'])
self.tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')

View File

@ -1,19 +1,19 @@
import io
import sys
sys.path.append('tts/vits')
sys.path.append('src/tts/vits')
import soundfile
import os
os.environ["PYTORCH_JIT"] = "0"
import torch
import tts.vits.commons as commons
import tts.vits.utils as utils
import src.tts.vits.commons as commons
import src.tts.vits.utils as utils
from tts.vits.models import SynthesizerTrn
from tts.vits.text.symbols import symbols
from tts.vits.text import text_to_sequence
from src.tts.vits.models import SynthesizerTrn
from src.tts.vits.text.symbols import symbols
from src.tts.vits.text import text_to_sequence
import logging
logging.getLogger().setLevel(logging.INFO)

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB