mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: inject
This commit is contained in:
@ -10,8 +10,8 @@ from .blackbox import Blackbox
|
|||||||
|
|
||||||
class ASR(Blackbox):
|
class ASR(Blackbox):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, path = ".env.yaml") -> None:
|
||||||
config = read_yaml(args[0])
|
config = read_yaml(path)
|
||||||
self.paraformer = RapidParaformer(config)
|
self.paraformer = RapidParaformer(config)
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
|
|||||||
@ -1,11 +1,17 @@
|
|||||||
from fastapi import Request, Response,status
|
from fastapi import Request, Response,status
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
from injector import inject
|
||||||
|
|
||||||
|
from blackbox.asr import ASR
|
||||||
|
from blackbox.tesou import Tesou
|
||||||
|
from blackbox.tts import TTS
|
||||||
|
|
||||||
from .blackbox import Blackbox
|
from .blackbox import Blackbox
|
||||||
|
|
||||||
class AudioChat(Blackbox):
|
class AudioChat(Blackbox):
|
||||||
|
|
||||||
def __init__(self, asr, gpt, tts):
|
@inject
|
||||||
|
def __init__(self, asr: ASR, gpt: Tesou, tts: TTS):
|
||||||
self.asr = asr
|
self.asr = asr
|
||||||
self.gpt = gpt
|
self.gpt = gpt
|
||||||
self.tts = tts
|
self.tts = tts
|
||||||
|
|||||||
@ -9,33 +9,33 @@ from .tesou import Tesou
|
|||||||
from .fastchat import Fastchat
|
from .fastchat import Fastchat
|
||||||
from .g2e import G2E
|
from .g2e import G2E
|
||||||
from .text_and_image import TextAndImage
|
from .text_and_image import TextAndImage
|
||||||
from injector import Injector
|
from injector import Injector, inject
|
||||||
|
|
||||||
class BlackboxFactory:
|
class BlackboxFactory:
|
||||||
models = {}
|
models = {}
|
||||||
|
|
||||||
def __init__(self) -> None:
|
@inject
|
||||||
injector = Injector()
|
def __init__(self,
|
||||||
self.models["audio_to_text"] = AudioToText()
|
audio_to_text: AudioToText,
|
||||||
self.models["text_to_audio"] = TextToAudio()
|
text_to_audio: TextToAudio,
|
||||||
self.models["asr"] = ASR(".env.yaml")
|
asr: ASR,
|
||||||
self.models["tts"] = TTS()
|
tts: TTS,
|
||||||
self.models["sentiment_engine"] = Sentiment()
|
sentiment_engine: Sentiment,
|
||||||
self.models["tesou"] = injector.get(Tesou)
|
tesou: Tesou,
|
||||||
self.models["fastchat"] = Fastchat()
|
fastchat: Fastchat,
|
||||||
self.models["audio_chat"] = AudioChat(self.models["asr"], self.models["tesou"], self.models["tts"])
|
audio_chat: AudioChat,
|
||||||
self.models["g2e"] = G2E()
|
g2e: G2E,
|
||||||
self.models["text_and_image"] = TextAndImage()
|
text_and_image:TextAndImage ) -> None:
|
||||||
# self.tts = TTS()
|
self.models["audio_to_text"] = audio_to_text
|
||||||
# self.asr = ASR(".env.yaml")
|
self.models["text_to_audio"] = text_to_audio
|
||||||
# self.sentiment = Sentiment()
|
self.models["asr"] = asr
|
||||||
# self.audio_to_text = AudioToText()
|
self.models["tts"] = tts
|
||||||
# self.text_to_audio = TextToAudio()
|
self.models["sentiment_engine"] = sentiment_engine
|
||||||
# self.tesou = injector.get(Tesou)
|
self.models["tesou"] = tesou
|
||||||
# self.fastchat = Fastchat()
|
self.models["fastchat"] = fastchat
|
||||||
# self.audio_chat = AudioChat(self.asr, self.tesou, self.tts)
|
self.models["audio_chat"] = audio_chat
|
||||||
# self.g2e = G2E()
|
self.models["g2e"] = g2e
|
||||||
# self.text_and_image = TextAndImage()
|
self.models["text_and_image"] = text_and_image
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
return self.processing(*args, **kwargs)
|
return self.processing(*args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user