feat: text to audio

This commit is contained in:
Dan Chen
2024-03-18 17:31:26 +08:00
parent 59d257b391
commit 8513270e9e
9 changed files with 63 additions and 14 deletions

View File

@ -2,20 +2,37 @@ from abc import ABC, abstractmethod
from fastapi import Request, Response
class Blackbox(ABC):
"""Blackbox class that provides a standard way to create an blackbox class using
inheritance. All blackbox classes should inherit from this class and implement
the methods processing, valid and fast_api_handler.
If implemented correctly, the blackbox class can be used in the main.py file
"""
def __init__(self, config: any) -> None:
pass
"""
processing method should return the processed data. The data is passed as an argument
to the method. All processing shouldn't interaction with the disk
but dist / list / string / bytes / io.BytesIO or other data type that in memory.
Output same as above.
"""
@abstractmethod
def processing(self, data: any):
async def processing(self, data: any) -> any:
pass
"""
valid method should return True if the data is valid and False if the data is invalid
"""
@abstractmethod
def valid(self, data: any) -> bool:
pass
"""
fast_api_handler method should return a fastapi Response object. This method is used
to handle the request from the fastapi server. The request object is passed as an argument
to the method.
"""
@abstractmethod
def fast_api_handler(self, request: Request) -> Response:
pass