|
|
|
|
|
|
|
|
|
|
|
|
|
|
from werkzeug.datastructures import FileStorage |
|
|
from werkzeug.datastructures import FileStorage |
|
|
|
|
|
|
|
|
|
|
|
from constants import AUDIO_EXTENSIONS |
|
|
from core.model_manager import ModelManager |
|
|
from core.model_manager import ModelManager |
|
|
from core.model_runtime.entities.model_entities import ModelType |
|
|
from core.model_runtime.entities.model_entities import ModelType |
|
|
from models.model import App, AppMode, AppModelConfig, Message |
|
|
from models.model import App, AppMode, AppModelConfig, Message |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE_SIZE = 30 |
|
|
FILE_SIZE = 30 |
|
|
FILE_SIZE_LIMIT = FILE_SIZE * 1024 * 1024 |
|
|
FILE_SIZE_LIMIT = FILE_SIZE * 1024 * 1024 |
|
|
ALLOWED_EXTENSIONS = ["mp3", "mp4", "mpeg", "mpga", "m4a", "wav", "webm", "amr"] |
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raise NoAudioUploadedServiceError() |
|
|
raise NoAudioUploadedServiceError() |
|
|
|
|
|
|
|
|
extension = file.mimetype |
|
|
extension = file.mimetype |
|
|
if extension not in [f"audio/{ext}" for ext in ALLOWED_EXTENSIONS]: |
|
|
|
|
|
|
|
|
if extension not in [f"audio/{ext}" for ext in AUDIO_EXTENSIONS]: |
|
|
raise UnsupportedAudioTypeServiceError() |
|
|
raise UnsupportedAudioTypeServiceError() |
|
|
|
|
|
|
|
|
file_content = file.read() |
|
|
file_content = file.read() |