mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
use gr.Error for audio length errors (#6672)
* use gr.Error for audio length errors * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
299f5e238b
commit
1234c3732b
5
.changeset/eager-snakes-boil.md
Normal file
5
.changeset/eager-snakes-boil.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:use gr.Error for audio length errors
|
@ -15,6 +15,7 @@ from gradio import processing_utils, utils
|
||||
from gradio.components.base import Component, StreamingInput, StreamingOutput
|
||||
from gradio.data_classes import FileData
|
||||
from gradio.events import Events
|
||||
from gradio.exceptions import Error
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
@ -190,11 +191,11 @@ class Audio(
|
||||
|
||||
duration = len(data) / sample_rate
|
||||
if self.min_length is not None and duration < self.min_length:
|
||||
raise ValueError(
|
||||
raise Error(
|
||||
f"Audio is too short, and must be at least {self.min_length} seconds"
|
||||
)
|
||||
if self.max_length is not None and duration > self.max_length:
|
||||
raise ValueError(
|
||||
raise Error(
|
||||
f"Audio is too long, and must be at most {self.max_length} seconds"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user