refac
This commit is contained in:
@@ -517,6 +517,11 @@ PASSWORD_VALIDATION_HINT = os.environ.get('PASSWORD_VALIDATION_HINT', '')
|
|||||||
|
|
||||||
BYPASS_MODEL_ACCESS_CONTROL = os.environ.get('BYPASS_MODEL_ACCESS_CONTROL', 'False').lower() == 'true'
|
BYPASS_MODEL_ACCESS_CONTROL = os.environ.get('BYPASS_MODEL_ACCESS_CONTROL', 'False').lower() == 'true'
|
||||||
|
|
||||||
|
# When enabled, skips pydub-based preprocessing (format conversion, compression,
|
||||||
|
# and chunked splitting) before sending files to processing engines. Useful when
|
||||||
|
# the upstream provider handles these steps or when ffmpeg is unavailable.
|
||||||
|
BYPASS_PYDUB_PREPROCESSING = os.environ.get('BYPASS_PYDUB_PREPROCESSING', 'False').lower() == 'true'
|
||||||
|
|
||||||
# When disabled (default), the OpenAI catch-all proxy endpoint (/{path:path})
|
# When disabled (default), the OpenAI catch-all proxy endpoint (/{path:path})
|
||||||
# is blocked. Enable only if you need direct passthrough to upstream OpenAI-
|
# is blocked. Enable only if you need direct passthrough to upstream OpenAI-
|
||||||
# compatible APIs for endpoints not natively handled by Open WebUI.
|
# compatible APIs for endpoints not natively handled by Open WebUI.
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ from open_webui.env import (
|
|||||||
AIOHTTP_CLIENT_SESSION_SSL,
|
AIOHTTP_CLIENT_SESSION_SSL,
|
||||||
AIOHTTP_CLIENT_TIMEOUT,
|
AIOHTTP_CLIENT_TIMEOUT,
|
||||||
AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST,
|
AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST,
|
||||||
|
BYPASS_PYDUB_PREPROCESSING,
|
||||||
DEVICE_TYPE,
|
DEVICE_TYPE,
|
||||||
ENABLE_FORWARD_USER_INFO_HEADERS,
|
ENABLE_FORWARD_USER_INFO_HEADERS,
|
||||||
)
|
)
|
||||||
@@ -1098,24 +1099,28 @@ def transcription_handler(request, file_path, metadata, user=None):
|
|||||||
def transcribe(request: Request, file_path: str, metadata: Optional[dict] = None, user=None):
|
def transcribe(request: Request, file_path: str, metadata: Optional[dict] = None, user=None):
|
||||||
log.info(f'transcribe: {file_path} {metadata}')
|
log.info(f'transcribe: {file_path} {metadata}')
|
||||||
|
|
||||||
if is_audio_conversion_required(file_path):
|
if BYPASS_PYDUB_PREPROCESSING:
|
||||||
file_path = convert_audio_to_mp3(file_path)
|
log.info('Bypassing pydub preprocessing (BYPASS_PYDUB_PREPROCESSING=true)')
|
||||||
|
chunk_paths = [file_path]
|
||||||
|
else:
|
||||||
|
if is_audio_conversion_required(file_path):
|
||||||
|
file_path = convert_audio_to_mp3(file_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_path = compress_audio(file_path)
|
file_path = compress_audio(file_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
|
||||||
# Always produce a list of chunk paths (could be one entry if small)
|
# Always produce a list of chunk paths (could be one entry if small)
|
||||||
try:
|
try:
|
||||||
chunk_paths = split_audio(file_path, MAX_FILE_SIZE)
|
chunk_paths = split_audio(file_path, MAX_FILE_SIZE)
|
||||||
print(f'Chunk paths: {chunk_paths}')
|
print(f'Chunk paths: {chunk_paths}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
detail=ERROR_MESSAGES.DEFAULT(e),
|
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||||
)
|
)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user