Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will not check process return code, but error #945

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions buzz/transcriber/file_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
"-ac", "1",
"-acodec", "pcm_s16le",
"-ar", str(SAMPLE_RATE),
"-loglevel", "error",
"-loglevel", "panic",
"-i", temp_output_path, wav_file]

try:
subprocess.run(cmd, capture_output=True, check=True)
except subprocess.CalledProcessError as exc:
logging.debug(f"Error processing downloaded audio: {exc.msg}")
raise Exception(exc.stderr.decode("utf-8"))
result = subprocess.run(cmd, capture_output=True)

if len(result.stderr):
logging.warning(f"Error processing downloaded audio. Error: {result.stderr.decode()}")
raise Exception(f"Error processing downloaded audio: {result.stderr.decode()}")

Check warning on line 71 in buzz/transcriber/file_transcriber.py

View check run for this annotation

Codecov / codecov/patch

buzz/transcriber/file_transcriber.py#L70-L71

Added lines #L70 - L71 were not covered by tests

self.transcription_task.file_path = wav_file
logging.debug(f"Downloaded audio to file: {self.transcription_task.file_path}")
Expand Down
20 changes: 14 additions & 6 deletions buzz/transcriber/openai_whisper_api_file_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@

mp3_file = tempfile.mktemp() + ".mp3"

cmd = ["ffmpeg", "-i", self.transcription_task.file_path, mp3_file]
cmd = [
"ffmpeg",
"-threads", "0",
"-loglevel", "panic",
"-i", self.transcription_task.file_path, mp3_file
]

try:
subprocess.run(cmd, capture_output=True, check=True)
except subprocess.CalledProcessError as exc:
logging.exception("")
raise Exception(exc.stderr.decode("utf-8"))
result = subprocess.run(cmd, capture_output=True)

if result.returncode != 0:
logging.warning(f"FFMPEG audio load warning. Process return code was not zero: {result.returncode}")

Check warning on line 52 in buzz/transcriber/openai_whisper_api_file_transcriber.py

View check run for this annotation

Codecov / codecov/patch

buzz/transcriber/openai_whisper_api_file_transcriber.py#L52

Added line #L52 was not covered by tests

if len(result.stderr):
logging.warning(f"FFMPEG audio load error. Error: {result.stderr.decode()}")
raise Exception(f"FFMPEG Failed to load audio: {result.stderr.decode()}")

Check warning on line 56 in buzz/transcriber/openai_whisper_api_file_transcriber.py

View check run for this annotation

Codecov / codecov/patch

buzz/transcriber/openai_whisper_api_file_transcriber.py#L55-L56

Added lines #L55 - L56 were not covered by tests

# fmt: off
cmd = [
Expand Down
2 changes: 1 addition & 1 deletion buzz/whisper_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load_audio(file: str, sr: int = SAMPLE_RATE):
"-ac", "1",
"-acodec", "pcm_s16le",
"-ar", str(sr),
"-loglevel", "error",
"-loglevel", "panic",
"-"
]
# fmt: on
Expand Down
Loading