mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-14 00:53:25 +00:00
feat: log
This commit is contained in:
@ -4,8 +4,6 @@ from typing import Any, Coroutine
|
||||
from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from ..log.log import Logger
|
||||
|
||||
from ..asr.rapid_paraformer.utils import read_yaml
|
||||
from ..asr.rapid_paraformer import RapidParaformer
|
||||
from .blackbox import Blackbox
|
||||
@ -15,8 +13,7 @@ from injector import singleton, inject
|
||||
class ASR(Blackbox):
|
||||
|
||||
@inject
|
||||
def __init__(self,logger: Logger,path = ".env.yaml") -> None:
|
||||
logger.info("ASR init")
|
||||
def __init__(self,path = ".env.yaml") -> None:
|
||||
config = read_yaml(path)
|
||||
self.paraformer = RapidParaformer(config)
|
||||
|
||||
@ -38,6 +35,7 @@ class ASR(Blackbox):
|
||||
async def fast_api_handler(self, request: Request) -> Response:
|
||||
data = (await request.form()).get("audio")
|
||||
if data is None:
|
||||
self.logger.warn("asr bag request","type", "fast_api_handler", "api", "asr")
|
||||
return JSONResponse(content={"error": "data is required"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
d = await data.read()
|
||||
try:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from fastapi import Request, Response,status
|
||||
from fastapi.responses import JSONResponse
|
||||
from injector import inject, singleton
|
||||
@ -8,11 +9,14 @@ from .tts import TTS
|
||||
|
||||
from .blackbox import Blackbox
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@singleton
|
||||
class AudioChat(Blackbox):
|
||||
|
||||
@inject
|
||||
def __init__(self, asr: ASR, gpt: Tesou, tts: TTS):
|
||||
logger.info("audio chat initint")
|
||||
self.asr = asr
|
||||
self.gpt = gpt
|
||||
self.tts = tts
|
||||
|
||||
@ -59,7 +59,7 @@ class BlackboxFactory:
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.processing(*args, **kwargs)
|
||||
|
||||
def call_blackbox(self, blackbox_name: str) -> Blackbox:
|
||||
def get_blackbox(self, blackbox_name: str) -> Blackbox:
|
||||
model = self.models.get(blackbox_name)
|
||||
if model is None:
|
||||
raise ValueError("Invalid Blackbox Type...")
|
||||
|
||||
Reference in New Issue
Block a user