|
54 | 54 | AIOHTTP_CLIENT_SESSION_SSL, |
55 | 55 | AIOHTTP_CLIENT_TIMEOUT, |
56 | 56 | AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST, |
| 57 | + BYPASS_PYDUB_PREPROCESSING, |
57 | 58 | DEVICE_TYPE, |
58 | 59 | ENABLE_FORWARD_USER_INFO_HEADERS, |
59 | 60 | ) |
@@ -1098,24 +1099,28 @@ def transcription_handler(request, file_path, metadata, user=None): |
1098 | 1099 | def transcribe(request: Request, file_path: str, metadata: Optional[dict] = None, user=None): |
1099 | 1100 | log.info(f'transcribe: {file_path} {metadata}') |
1100 | 1101 |
|
1101 | | - if is_audio_conversion_required(file_path): |
1102 | | - file_path = convert_audio_to_mp3(file_path) |
| 1102 | + if BYPASS_PYDUB_PREPROCESSING: |
| 1103 | + log.info('Bypassing pydub preprocessing (BYPASS_PYDUB_PREPROCESSING=true)') |
| 1104 | + chunk_paths = [file_path] |
| 1105 | + else: |
| 1106 | + if is_audio_conversion_required(file_path): |
| 1107 | + file_path = convert_audio_to_mp3(file_path) |
1103 | 1108 |
|
1104 | | - try: |
1105 | | - file_path = compress_audio(file_path) |
1106 | | - except Exception as e: |
1107 | | - log.exception(e) |
| 1109 | + try: |
| 1110 | + file_path = compress_audio(file_path) |
| 1111 | + except Exception as e: |
| 1112 | + log.exception(e) |
1108 | 1113 |
|
1109 | | - # Always produce a list of chunk paths (could be one entry if small) |
1110 | | - try: |
1111 | | - chunk_paths = split_audio(file_path, MAX_FILE_SIZE) |
1112 | | - print(f'Chunk paths: {chunk_paths}') |
1113 | | - except Exception as e: |
1114 | | - log.exception(e) |
1115 | | - raise HTTPException( |
1116 | | - status_code=status.HTTP_400_BAD_REQUEST, |
1117 | | - detail=ERROR_MESSAGES.DEFAULT(e), |
1118 | | - ) |
| 1114 | + # Always produce a list of chunk paths (could be one entry if small) |
| 1115 | + try: |
| 1116 | + chunk_paths = split_audio(file_path, MAX_FILE_SIZE) |
| 1117 | + print(f'Chunk paths: {chunk_paths}') |
| 1118 | + except Exception as e: |
| 1119 | + log.exception(e) |
| 1120 | + raise HTTPException( |
| 1121 | + status_code=status.HTTP_400_BAD_REQUEST, |
| 1122 | + detail=ERROR_MESSAGES.DEFAULT(e), |
| 1123 | + ) |
1119 | 1124 |
|
1120 | 1125 | results = [] |
1121 | 1126 | try: |
|
0 commit comments