From f7f75431aafe8f7fc8145a00afcf137bfea19e8a Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 17 Nov 2024 18:13:53 -0700 Subject: [PATCH] Add option video_file parameter to ASR. --- subgen.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/subgen.py b/subgen.py index dfe6357..40f64b0 100644 --- a/subgen.py +++ b/subgen.py @@ -329,6 +329,7 @@ def batch( async def asr( task: Union[str, None] = Query(default="transcribe", enum=["transcribe", "translate"]), language: Union[str, None] = Query(default=None), + video_file: Union[str, None] = Query(default="Name not supplied"), initial_prompt: Union[str, None] = Query(default=None), #not used by Bazarr audio_file: UploadFile = File(...), encode: bool = Query(default=True, description="Encode audio first through ffmpeg"), #not used by Bazarr/always False @@ -336,7 +337,7 @@ async def asr( word_timestamps: bool = Query(default=False, description="Word level timestamps") #not used by Bazarr ): try: - logging.info(f"Transcribing file from Bazarr/ASR webhook") + logging.info(f"Transcribing file '{video_file}' from Bazarr/ASR webhook") result = None random_name = ''.join(random.choices("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", k=6)) @@ -370,9 +371,9 @@ async def asr( appendLine(result) elapsed_time = time.time() - start_time minutes, seconds = divmod(int(elapsed_time), 60) - logging.info(f"Bazarr transcription is completed, it took {minutes} minutes and {seconds} seconds to complete.") + logging.info(f"Transcription of '{video_file}' from Bazarr complete, it took {minutes} minutes and {seconds} seconds to complete.") except Exception as e: - logging.info(f"Error processing or transcribing Bazarr {audio_file.filename}: {e}") + logging.info(f"Error processing or transcribing Bazarr file: {video_file} -- Exception: {e}") finally: await audio_file.close() task_queue.task_done()