feat: add log for asr

pull/21891/head
ytqh 1 year ago
parent b35f6a3f0a
commit a222a038a2

@ -3,19 +3,16 @@ 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 ( from services.errors.audio import (AudioTooLargeServiceError,
AudioTooLargeServiceError, NoAudioUploadedServiceError,
NoAudioUploadedServiceError, ProviderNotSupportSpeechToTextServiceError,
ProviderNotSupportSpeechToTextServiceError, ProviderNotSupportTextToSpeechServiceError,
ProviderNotSupportTextToSpeechServiceError, UnsupportedAudioTypeServiceError)
UnsupportedAudioTypeServiceError, from werkzeug.datastructures import FileStorage
)
FILE_SIZE = 30 FILE_SIZE = 30
FILE_SIZE_LIMIT = FILE_SIZE * 1024 * 1024 FILE_SIZE_LIMIT = FILE_SIZE * 1024 * 1024
@ -43,6 +40,8 @@ class AudioService:
if file is None: if file is None:
raise NoAudioUploadedServiceError() raise NoAudioUploadedServiceError()
logger.info(f"asr info: {file.filename}, {file.content_type}, {file.content_length}, {file.headers}")
extension = file.mimetype extension = file.mimetype
if extension not in [f"audio/{ext}" for ext in AUDIO_EXTENSIONS]: if extension not in [f"audio/{ext}" for ext in AUDIO_EXTENSIONS]:
raise UnsupportedAudioTypeServiceError() raise UnsupportedAudioTypeServiceError()
@ -77,10 +76,9 @@ 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():

Loading…
Cancel
Save