From f7b0d48c6fb058fc5238f2d101fa5c85490434a5 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 23 Aug 2023 15:10:41 +0200 Subject: [PATCH] Add info logging to failable functions --- verbanote/file_operations.py | 1 + verbanote/process.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/verbanote/file_operations.py b/verbanote/file_operations.py index 13c39d0..21656a4 100644 --- a/verbanote/file_operations.py +++ b/verbanote/file_operations.py @@ -23,6 +23,7 @@ def upload_to_oxo(file: Path, url: str = "https://0x0.st", expires: int = 2) -> ) if not resp.ok: raise requests.exceptions.HTTPError() + logging.info(f"Uploaded file {file} to {str(resp.content)}") return str(resp.content) diff --git a/verbanote/process.py b/verbanote/process.py index 3020549..8058609 100644 --- a/verbanote/process.py +++ b/verbanote/process.py @@ -1,3 +1,4 @@ +import logging import os import re import json @@ -43,11 +44,13 @@ def transcribe( f = {Path.joinpath(output_path, str(i))} audio_f = f"{f}.wav" json_f = f"{f}.json" + logging.info(f"Starting transcription of {str(audio_f)}...") result = model.transcribe( audio=audio_f, language=lang, word_timestamps=word_timestamps ) with open(json_f, "w") as outfile: json.dump(result, outfile, indent=4) + logging.info(f"Transcription written to {str(json_f)}.") # TODO clean up this mess @@ -65,6 +68,7 @@ def output_txt(diarized_groups: list, transcription_path: Path) -> TxtTranscript with open(f"{Path.joinpath(transcription_path, str(gidx))}.json") as f: captions = json.load(f)["segments"] + logging.info(f"Loaded {fname} for transcription...") if captions: speaker = g[0].split()[-1] @@ -95,6 +99,7 @@ def _add_audio_silence(audiofile) -> Path: audio = spacer.append(audio, crossfade=0) out_file = Path.joinpath(Path(os.path.dirname(audiofile)), "interview_prepend.wav") audio.export(out_file, format="wav") + logging.info(f"Exported audiofile with silence prepended to {fname}.") return out_file @@ -113,6 +118,7 @@ def _save_individual_audio_files( audio[start:end].export( f"{Path.joinpath(output_path, str(gidx))}.wav", format="wav" ) + logging.info(f"Exported audiopart {gidx} of {len(groups)} to {fname}.") def _group_speakers(diarization_file: Path) -> list: