mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
make_waveform: raise exception if ffmpeg fails (#4578)
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
fa17457d07
commit
4d1ad7c820
@ -10,7 +10,7 @@
|
||||
- Restored missing imports in `gr.components` by [@abidlabs](https://github.com/abidlabs) in [PR 4566](https://github.com/gradio-app/gradio/pull/4566)
|
||||
- Fix bug where `select` event was not triggered in `gr.Gallery` if `height` was set to be large with `allow_preview=False` by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4551](https://github.com/gradio-app/gradio/pull/4551)
|
||||
- Fix bug where setting `visible=False` in `gr.Group` event did not work by [@abidlabs](https://github.com/abidlabs) in [PR 4567](https://github.com/gradio-app/gradio/pull/4567)
|
||||
- Fix `make_waveform` to work with paths that contain spaces [@akx](https://github.com/akx) in [PR 4567](https://github.com/gradio-app/gradio/pull/4570)
|
||||
- Fix `make_waveform` to work with paths that contain spaces [@akx](https://github.com/akx) in [PR 4570](https://github.com/gradio-app/gradio/pull/4570) & [PR 4578](https://github.com/gradio-app/gradio/pull/4578)
|
||||
- Send captured data in `stop_recording` event for `gr.Audio` and `gr.Video` components by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4554](https://github.com/gradio-app/gradio/pull/4554)
|
||||
- Fix bug in `gr.Gallery` where `height` and `object_fit` parameters where being ignored by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4576](https://github.com/gradio-app/gradio/pull/4576)
|
||||
- Fixes an HTML sanitization issue in DOMPurify where links in markdown were not opening in a new window by [@hannahblair] in [PR 4577](https://github.com/gradio-app/gradio/pull/4577)
|
||||
|
@ -853,7 +853,7 @@ def make_waveform(
|
||||
output_mp4.name,
|
||||
]
|
||||
|
||||
subprocess.call(ffmpeg_cmd)
|
||||
subprocess.check_call(ffmpeg_cmd)
|
||||
return output_mp4.name
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
@ -406,3 +407,19 @@ def test_make_waveform_with_spaces_in_filename():
|
||||
shutil.copy("test/test_files/audio_sample.wav", audio)
|
||||
waveform = gr.make_waveform(audio)
|
||||
assert waveform.endswith(".mp4")
|
||||
|
||||
|
||||
def test_make_waveform_raises_if_ffmpeg_fails(tmp_path, monkeypatch):
|
||||
"""
|
||||
Test that make_waveform raises an exception if ffmpeg fails,
|
||||
instead of returning a path to a non-existent or empty file.
|
||||
"""
|
||||
audio = tmp_path / "test audio.wav"
|
||||
shutil.copy("test/test_files/audio_sample.wav", audio)
|
||||
|
||||
def _failing_ffmpeg(*args, **kwargs):
|
||||
raise subprocess.CalledProcessError(1, "ffmpeg")
|
||||
|
||||
monkeypatch.setattr(subprocess, "call", _failing_ffmpeg)
|
||||
with pytest.raises(Exception):
|
||||
gr.make_waveform(str(audio))
|
||||
|
Loading…
Reference in New Issue
Block a user