Add info logging to failable functions
This commit is contained in:
parent
6cccf00df4
commit
f7b0d48c6f
2 changed files with 7 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue