|
|
|
@ -3,16 +3,19 @@ import logging
|
|
|
|
import uuid
|
|
|
|
import uuid
|
|
|
|
from typing import Optional
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from werkzeug.datastructures import FileStorage
|
|
|
|
|
|
|
|
|
|
|
|
from constants import AUDIO_EXTENSIONS
|
|
|
|
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
|
|
|
|
from services.errors.audio import (AudioTooLargeServiceError,
|
|
|
|
from services.errors.audio import (
|
|
|
|
NoAudioUploadedServiceError,
|
|
|
|
AudioTooLargeServiceError,
|
|
|
|
ProviderNotSupportSpeechToTextServiceError,
|
|
|
|
NoAudioUploadedServiceError,
|
|
|
|
ProviderNotSupportTextToSpeechServiceError,
|
|
|
|
ProviderNotSupportSpeechToTextServiceError,
|
|
|
|
UnsupportedAudioTypeServiceError)
|
|
|
|
ProviderNotSupportTextToSpeechServiceError,
|
|
|
|
from werkzeug.datastructures import FileStorage
|
|
|
|
UnsupportedAudioTypeServiceError,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
FILE_SIZE = 30
|
|
|
|
FILE_SIZE = 30
|
|
|
|
FILE_SIZE_LIMIT = FILE_SIZE * 1024 * 1024
|
|
|
|
FILE_SIZE_LIMIT = FILE_SIZE * 1024 * 1024
|
|
|
|
@ -76,9 +79,10 @@ class AudioService:
|
|
|
|
):
|
|
|
|
):
|
|
|
|
from collections.abc import Generator
|
|
|
|
from collections.abc import Generator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from flask import Response, stream_with_context
|
|
|
|
|
|
|
|
|
|
|
|
from app import app
|
|
|
|
from app import app
|
|
|
|
from extensions.ext_database import db
|
|
|
|
from extensions.ext_database import db
|
|
|
|
from flask import Response, stream_with_context
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def invoke_tts(text_content: str, app_model: App, voice: Optional[str] = None):
|
|
|
|
def invoke_tts(text_content: str, app_model: App, voice: Optional[str] = None):
|
|
|
|
with app.app_context():
|
|
|
|
with app.app_context():
|
|
|
|
|