mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: calculator;
This commit is contained in:
@ -7,7 +7,6 @@ from blackbox.text_to_audio import TextToAudio
|
|||||||
class BlackboxFactory:
|
class BlackboxFactory:
|
||||||
|
|
||||||
def create_blackbox(self, blackbox_type: str, blackbox_config: dict) -> Blackbox:
|
def create_blackbox(self, blackbox_type: str, blackbox_config: dict) -> Blackbox:
|
||||||
|
|
||||||
if blackbox_type == "audio_to_text":
|
if blackbox_type == "audio_to_text":
|
||||||
return AudioToText(blackbox_config)
|
return AudioToText(blackbox_config)
|
||||||
if blackbox_type == "text_to_audio":
|
if blackbox_type == "text_to_audio":
|
||||||
|
|||||||
@ -4,12 +4,12 @@ from blackbox.blackbox import Blackbox
|
|||||||
|
|
||||||
|
|
||||||
class Calculator(Blackbox):
|
class Calculator(Blackbox):
|
||||||
|
|
||||||
"""This class just for example, it show how to implement Blackbox interface."""
|
|
||||||
|
|
||||||
|
"""This class just for example, it show how to implement Blackbox interface."""
|
||||||
|
|
||||||
def valid(self, data: any) -> bool:
|
def valid(self, data: any) -> bool:
|
||||||
return isinstance(data, dict) and "op" in data and "left" in data and "right" in data
|
return isinstance(data, dict) and "op" in data and "left" in data and "right" in data
|
||||||
|
|
||||||
def processing(self, data: dict) -> any:
|
def processing(self, data: dict) -> any:
|
||||||
if not self.valid(data):
|
if not self.valid(data):
|
||||||
raise ValueError("Invalid data")
|
raise ValueError("Invalid data")
|
||||||
|
|||||||
@ -5,6 +5,7 @@ from gtts import gTTS
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
class TextToAudio(Blackbox):
|
class TextToAudio(Blackbox):
|
||||||
|
|
||||||
def valid(self, data: any) -> bool:
|
def valid(self, data: any) -> bool:
|
||||||
return isinstance(data, str)
|
return isinstance(data, str)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user