1
0
Fork 0
TakwayDisplayPlatform/app/abstract.py

41 lines
984 B
Python
Raw Normal View History

2024-06-09 22:54:13 +08:00
from abc import ABC, abstractmethod
#------ 抽象 ASR, LLM, TTS 类 ------ #
class ASR(ABC):
@abstractmethod
async def stream_recognize(self, chunk):
pass
class LLM(ABC):
@abstractmethod
def chat(self, assistant, prompt, db):
pass
class TTS(ABC):
@abstractmethod
def synthetize(self, assistant, text):
pass
# --------------------------------- #
# ----------- 抽象服务类 ----------- #
class UserAudioService(ABC):
@abstractmethod
def user_audio_process(self, audio:str, **kwargs) -> str:
pass
class PromptService(ABC):
@abstractmethod
def prompt_process(self, prompt:str, **kwargs) -> str:
pass
class LLMMsgService(ABC):
@abstractmethod
2024-06-10 20:49:50 +08:00
def llm_msg_process(self, llm_chunks:list, **kwargs) -> list:
2024-06-09 22:54:13 +08:00
pass
class TTSAudioService(ABC):
@abstractmethod
def tts_audio_process(self, audio:bytes, **kwargs) -> bytes:
pass
# --------------------------------- #