Skip to content

Commit

Permalink
include nice error message in check audio format
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi authored and devxpy committed Oct 31, 2023
1 parent 336cda2 commit d9a7e48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion daras_ai_v2/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,13 @@ def check_wav_audio_format(filename: str) -> bool:
filename,
]
print("\t$ " + " ".join(args))
data = json.loads(subprocess.check_output(args))
try:
data = json.loads(subprocess.check_output(args, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
ffmpeg_output_error = ValueError(e.output, e)
raise ValueError(
"Invalid audio file. Please confirm the file is not corrupted and has a supported format (google 'ffmpeg supported audio file types')"
) from ffmpeg_output_error
return (
len(data["streams"]) == 1
and data["streams"][0]["codec_name"] == "pcm_s16le"
Expand Down

0 comments on commit d9a7e48

Please sign in to comment.