text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 190
values | source_page_title stringclasses 190
values |
|---|---|---|---|
he layout but still exist in the DOM
interactive: bool
default `= True`
if False, the Button will be in a disabled state.
elem_id: str | None
default `= None`
an optional string that is assigned as the id of this component in the HTML
DOM. Can be used for targeting CSS styles.
... | Initialization | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
m pixel width, will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower than
min_width, the min_width parameter will be respected first.
| Initialization | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
Shortcuts
gradio.DuplicateButton
Interface String Shortcut `"duplicatebutton"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The DuplicateButton component supports the ... | Event Listeners | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
empty list.
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to a string, the endpoint will be exposed in the API docs with the given
name. If None (default), the name of the function will be used as the API
endpoint.
... | Event Listeners | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
nput values for each parameter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a tuple of lists (even if there is only 1 output
component), with each list in the tuple corresponding to one output component.
max_batch_size: int
defau... | Event Listeners | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
vided as either a function
or a raw code string. A function receives the values of 'inputs' and 'outputs'
as arguments; raw code can access them through `arguments`. Return a list of
values for the output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
If set, this... | Event Listeners | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
ed,
this function will be executed first with queue=False, and only if it
completes successfully will the main function be called. The validator
receives the same inputs as the main function, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must accept those
keyword names. It should r... | Event Listeners | https://gradio.app/docs/gradio/duplicatebutton | Gradio - Duplicatebutton Docs |
Creates a component to displays a base image and colored annotations on top
of that image. Annotations can take the from of rectangles (e.g. object
detection) or masks (e.g. image segmentation). As this component does not
accept user input, it is rarely used as an input component.
| Description | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
**Using AnnotatedImage as an input component.**
How AnnotatedImage will pass its value to your function:
Type: `tuple[str, list[tuple[str, str]]] | None`
Passes its value as a `tuple` consisting of:
* `str` filepath to a base image
* `list` of annotations.
* Each annotation itself is a `tuple` of a mask (... | Behavior | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Parameters ▼
value: tuple[np.ndarray | PIL.Image.Image | str, list[tuple[np.ndarray | tuple[int, int, int, int], str]]] | None
default `= None`
Tuple of base image and list of (annotation, label) pairs.
format: str
default `= "webp"`
Format used to save images before it is returned t... | Initialization | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
ect otherwise). Can provide a Timer whose tick resets `value`, or a float
that provides the regular interval for the reset Timer.
inputs: Component | list[Component] | set[Component] | None
default `= None`
Components that are used as inputs to calculate `value` if `value` is a
function (has no effect... | Initialization | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
e rendered in the Blocks context. Should
be used if the intention is to assign event listeners now but render the
component later.
key: int | str | tuple[int | str, ...] | None
default `= None`
in a gr.render, Components with the same key across re-renders are treated as
the same component, not a new ... | Initialization | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Shortcuts
gradio.AnnotatedImage
Interface String Shortcut `"annotatedimage"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
image_segmentation
| Demos | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The AnnotatedImage component supports the f... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
his should be an empty list.
outputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
api_name: str | None
d... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
ut this event on the queue, even if the queue has been
enabled. If None, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each parameter. The lists should be... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
while pending, and "always_last" (default for
`.change()` and `.key_up()` events) would allow a second submission after the
pending event is complete.
js: str | Literal[True] | None
default `= None`
Optional frontend JavaScript to run before 'fn', provided as either a function
or a raw code string. A ... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
t listener to be used in @gr.render(). If set, this
value identifies an event as identical across re-renders when the key is
identical.
validator: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function will be executed first with queue... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Any code in a `if gr.NO_RELOAD` code-block will not be re-evaluated when
the source file is reloaded. This is helpful for importing modules that do not
like to be reloaded (tiktoken, numpy) as well as database connections and long
running set up code.
| Description | https://gradio.app/docs/gradio/NO_RELOAD | Gradio - No_Reload Docs |
import gradio as gr
if gr.NO_RELOAD:
from transformers import pipeline
pipe = pipeline("text-classification", model="cardiffnlp/twitter-roberta-base-sentiment-latest")
gr.Interface.from_pipeline(pipe).launch()
| Example Usage | https://gradio.app/docs/gradio/NO_RELOAD | Gradio - No_Reload Docs |
Creates an image component that, as an input, can be used to upload and
edit images using simple editing tools such as brushes, strokes, cropping, and
layers. Or, as an output, this component can be used to display images.
| Description | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
**Using ImageEditor as an input component.**
How ImageEditor will pass its value to your function:
Type: `EditorValue | None`
Passes the uploaded images as an instance of EditorValue, which is just a
`dict` with keys: 'background', 'layers', and 'composite'.
* The values corresponding to 'background' and 'composi... | Behavior | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
Parameters ▼
value: EditorValue | ImageType | None
default `= None`
Optional initial image(s) to populate the image editor. Should be a dictionary
with keys: `background`, `layers`, and `composite`. The values corresponding
to `background` and `composite` should be images or None, while `layers`
shoul... | Initialization | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
und and composite are filled with white, while
layers only have their alpha dropped. In "RGBA" mode, the color values under
fully transparent pixels are arbitrary (zero after an edit), so composite the
image onto a background yourself, or use "RGB", instead of slicing off the
alpha channel. See
https://pillow.readthedo... | Initialization | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
effect otherwise). Can provide a Timer whose tick resets `value`, or a float
that provides the regular interval for the reset Timer.
inputs: Component | list[Component] | set[Component] | None
default `= None`
Components that are used as inputs to calculate `value` if `value` is a
function (has no eff... | Initialization | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
ut or output.
visible: bool | Literal['hidden']
default `= True`
If False, component will be hidden. If "hidden", component will be visually
hidden and not take up space in the layout but still exist in the DOM
elem_id: str | None
default `= None`
An optional string that is assigned ... | Initialization | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
The transforms tools to make available to users. "crop" allows the user to
crop the image.
eraser: Eraser | None | Literal[False]
default `= None`
The options for the eraser tool in the image editor. Should be an instance of
the `gr.Eraser` class, or None to use the default settings. Can also be Fals... | Initialization | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
canvas size will not change based on the size of the background
image and the image will be rescaled to fit (while preserving the aspect
ratio) and placed in the center of the canvas.
webcam_options: WebcamOptions | None
default `= None`
The options for the webcam tool in the image editor. Can be an ... | Initialization | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
Shortcuts
gradio.ImageEditor
Interface String Shortcut `"imageeditor"`
Initialization Uses default values
gradio.Sketchpad
Interface String Shortcut `"sketchpad"`
Initialization Uses sources=(), brush=Brush(colors=["000000"],
color_mode="fixed")
gradio.Paint
Interface S... | Shortcuts | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
image_editor
| Demos | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The ImageEditor component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
function to call when this event is triggered. Often a machine learning
model's prediction function. Each parameter of the function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in the tuple corresponding to one output component.
... | Event Listeners | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
nt area as well as a runtime display in
the upper right corner, "minimal" only shows the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will s... | Event Listeners | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
ll cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'alway... | Event Listeners | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
s endpoint. Can be "public"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
... | Event Listeners | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
Helper Classes | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs | |
gradio.Brush(···)
Description
A dataclass for specifying options for the brush tool in the ImageEditor
component. An instance of this class can be passed to the `brush` parameter of
`gr.ImageEditor`.
Initialization
Parameters ▼
default_size: int | Literal['auto']
default `= "auto"`
The default rad... | Brush | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
gradio.Eraser(···)
Description
A dataclass for specifying options for the eraser tool in the ImageEditor
component. An instance of this class can be passed to the `eraser` parameter
of `gr.ImageEditor`.
Initialization
Parameters ▼
default_size: int | Literal['auto']
default `= "auto"`
The default ... | Eraser | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
gradio.LayerOptions(···)
Description
A dataclass for specifying options for the layer tool in the ImageEditor
component. An instance of this class can be passed to the `layers` parameter
of `gr.ImageEditor`.
Initialization
Parameters ▼
allow_additional_layers: bool
default `= True`
If True, users ... | Layer Options | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
gradio.WebcamOptions(···)
Description
A dataclass for specifying options for the webcam tool in the ImageEditor
component. An instance of this class can be passed to the `webcam_options`
parameter of `gr.ImageEditor`.
Initialization
Parameters ▼
mirror: bool
default `= True`
If True, the webcam wi... | Webcam Options | https://gradio.app/docs/gradio/imageeditor | Gradio - Imageeditor Docs |
The Progress class provides a custom progress tracker that is used in a
function signature. To attach a Progress tracker to a function, simply add a
parameter right after the input parameters that has a default value set to a
`gradio.Progress()` instance. The Progress tracker can then be updated in the
function by call... | Description | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
import gradio as gr
import time
def my_function(x, progress=gr.Progress()):
progress(0, desc="Starting...")
time.sleep(1)
for i in progress.tqdm(range(100)):
time.sleep(0.1)
return x
gr.Interface(my_function, gr.Textbox(), gr.Textbox()).queue().launch()
| Example Usage | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
Parameters ▼
track_tqdm: bool
default `= False`
If True, the Progress object will track any tqdm.tqdm iterations with the tqdm
library in the function.
| Initialization | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
Methods | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
20512'%3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
None if unknown. If None, hides progress bar.
desc: str | None
default `= None`
description to display.
total: int | float | None
default `= None`
estimated total number of steps.
unit: str
default `= "steps"`
unit of iterations.
| __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
2'%3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%2... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
total number of steps.
unit: str
default `= "steps"`
unit of iterations.
[Progress Bars](../../guides/progress-bars/)
| tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
20512'%3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
None if unknown. If None, hides progress bar.
desc: str | None
default `= None`
description to display.
total: int | float | None
default `= None`
estimated total number of steps.
unit: str
default `= "steps"`
unit of iterations.
| __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
2'%3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%2... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
total number of steps.
unit: str
default `= "steps"`
unit of iterations.
| tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
Used to create an upload button, when clicked allows a user to upload files
that satisfy the specified file type or generic files (if file_type not set).
| Description | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
**Using UploadButton as an input component.**
How UploadButton will pass its value to your function:
Type: `bytes | str | list[bytes] | list[str] | None`
Passes the file as a `str` or `bytes` object, or a list of `str` or list of
`bytes` objects, depending on `type` and `file_count`.
Example Code
... | Behavior | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Parameters ▼
label: str
default `= "Upload a File"`
Text to display on the button. Defaults to "Upload a File".
value: str | I18nData | list[str] | Callable | None
default `= None`
File or list of files to upload by default.
every: Timer | float | None
default `= Non... | Initialization | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
width: int | None
default `= None`
minimum pixel width, will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower than
min_width, the min_width parameter will be respected first.
interactive: bool
default `= True`
If False, the ... | Initialization | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
th the same base name as the uploaded file, whose full path can be
retrieved by file_obj.name, "binary" returns an bytes object.
file_count: Literal['single', 'multiple', 'directory']
default `= "single"`
if single, allows user to upload one file. If "multiple", user uploads
multiple files. If "direct... | Initialization | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Shortcuts
gradio.UploadButton
Interface String Shortcut `"uploadbutton"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
upload_and_downloadupload_button
| Demos | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The UploadButton component supports the fol... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to a string, the endpoint will be exposed i... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each parameter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a tuple of lists (even if there is only 1 o... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
omplete.
js: str | Literal[True] | None
default `= None`
Optional frontend JavaScript to run before 'fn', provided as either a function
or a raw code string. A function receives the values of 'inputs' and 'outputs'
as arguments; raw code can access them through `arguments`. Return a list of
values for... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
validator: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function will be executed first with queue=False, and only if it
completes successfully will the main function be called. The validator
receives the same inputs as the main function, i... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Creates an audio component that can be used to upload/record audio (as an
input) or display audio (as an output).
| Description | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
**Using Audio as an input component.**
How Audio will pass its value to your function:
Type: `str | tuple[int, np.ndarray] | None`
Passes audio as one of these formats (depending on `type`):
* `str` filepath
* `tuple` of (sample rate in Hz, audio data as numpy array).
* The audio data is a 16-bit `int` ar... | Behavior | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
Parameters ▼
value: str | Path | tuple[int, np.ndarray] | Callable | None
default `= None`
A path, URL, or [sample_rate, numpy array] tuple (sample rate in Hz, audio
data as a float or int numpy array) for the default value that Audio component
is going to take. If a function is provided, the function... | Initialization | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
set[Component] | None
default `= None`
Components that are used as inputs to calculate `value` if `value` is a
function (has no effect otherwise). `value` is recalculated any time the
inputs change.
show_label: bool | None
default `= None`
if True, will display label.
container: boo... | Initialization | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
elem_id: str | None
default `= None`
An optional string that is assigned as the id of this component in the HTML
DOM. Can be used for targeting CSS styles.
elem_classes: list[str] | str | None
default `= None`
An optional list of strings that are assigned as the classes of this component
in... | Initialization | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
and the audio is kept as is. In the case where output audio is
returned from the prediction function as numpy array and no `format` is
provided, it will be returned as a "wav" file.
autoplay: bool
default `= False`
Whether to automatically play the audio when the component is used as an
output. Note:... | Initialization | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
phone
if the source is set to "microphone". Defaults to False.
subtitles: str | Path | list[dict[str, Any]] | None
default `= None`
A subtitle file (srt, vtt, or json) for the audio, or a list of subtitle
dictionaries in the format [{"text": str, "timestamp": [start, end]}] where
timestamps are in sec... | Initialization | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
Shortcuts
gradio.Audio
Interface String Shortcut `"audio"`
Initialization Uses default values
gradio.Microphone
Interface String Shortcut `"microphone"`
Initialization Uses sources=["microphone"]
| Shortcuts | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
generate_tonereverse_audio
| Demos | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The Audio component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
r stops recording with the Audio.
Audio.upload(fn, ···)
This listener is triggered when the user uploads a file into the Audio.
Audio.input(fn, ···)
This listener is triggered when the user changes the value of the Audio.
Event Parameters
Parameters ▼
fn: Callable | Non... | Event Listeners | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
f False, then no description will be displayed in the
API docs.
scroll_to_output: bool
default `= False`
If True, will scroll to output component on completion
show_progress: Literal['full', 'minimal', 'hidden']
default `= "minimal"`
how to show the progress animation while event is ... | Event Listeners | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
with the `Image`
component).
postprocess: bool
default `= True`
If False, will not run postprocessing of component data before returning 'fn'
output to the browser.
cancels: dict[str, Any] | list[dict[str, Any]] | None
default `= None`
A list of other events to cancel when this liste... | Event Listeners | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
)`, which itself is 1 by default).
concurrency_id: str | None
default `= None`
If set, this is the id of the concurrency group. Events with the same
concurrency_id will be limited by the lowest set concurrency_limit.
api_visibility: Literal['public', 'private', 'undocumented']
default... | Event Listeners | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
Helper Classes | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs | |
gradio.WaveformOptions(···)
Description
A dataclass for specifying options for the waveform display in the Audio
component. An instance of this class can be passed into the `waveform_options`
parameter of `gr.Audio`.
Initialization
Parameters ▼
waveform_color: str | None
default `= None`
The color... | WaveformOptions | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
Validates that the audio length is within the specified min and max length (in
seconds). You can use this to construct a validator that will check if the
user-provided audio is either too short or too long.
import gradio as gr
demo = gr.Interface(
lambda x: x,
inputs="audio",
... | is_audio_correct_length | https://gradio.app/docs/gradio/audio | Gradio - Audio Docs |
The gr.CopyData class is a subclass of gr.EventData that specifically
carries information about the `.copy()` event. When gr.CopyData is added as a
type hint to an argument of an event listener method, a gr.CopyData object
will automatically be passed as the value of that argument. The attributes of
this object contain... | Description | https://gradio.app/docs/gradio/copydata | Gradio - Copydata Docs |
import gradio as gr
def on_copy(copy_data: gr.CopyData):
return f"Copied text: {copy_data.value}"
with gr.Blocks() as demo:
textbox = gr.Textbox("Hello World!")
copied = gr.Textbox()
textbox.copy(on_copy, None, copied)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/copydata | Gradio - Copydata Docs |
Parameters ▼
value: Any
The value that was copied.
| Attributes | https://gradio.app/docs/gradio/copydata | Gradio - Copydata Docs |
Sets up an event listener that triggers a function when the specified
event(s) occur. This is especially useful when the same function should be
triggered by multiple events. Only a single API endpoint is generated for all
events in the triggers list.
| Description | https://gradio.app/docs/gradio/on | Gradio - On Docs |
import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
input = gr.Textbox()
button = gr.Button("Submit")
output = gr.Textbox()
gr.on(
triggers=[button.click, input.submit],
fn=lambda x: x,
inputs=[input],
outp... | Example Usage | https://gradio.app/docs/gradio/on | Gradio - On Docs |
Parameters ▼
triggers: list[Trigger] | Trigger | None
default `= None`
List of triggers to listen to, e.g. [btn.click, number.change]. If None, will
run on app load and changes to any inputs.
fn: Callable[..., Any] | None | Literal['decorator']
default `= "decorator"`
the function to... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to a string, the endpoint will be exposed in the API docs with the given
name. If None (default), the name of the function will be used as the API
endpoint.
api_descrip... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
ault `= 4`
Maximum number of inputs to batch together if this is called from the queue
(only relevant if batch=True)
preprocess: bool
default `= True`
If False, will not run preprocessing of component data before running 'fn'
(e.g. leaving it as a base64 string if this method is called with the `Imag... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
mum number of this event that can be running
simultaneously. Can be set to None to mean no concurrency_limit (any number of
this event can be running simultaneously). Set to "default" to use the default
concurrency limit (defined by the `default_concurrency_limit` parameter in
`Blocks.queue()`, which itself is 1 by def... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
Special component that ticks at regular intervals when active. It is not
visible, and only used to trigger events at a regular interval through the
`tick` event listener.
| Description | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
**Using Timer as an input component.**
How Timer will pass its value to your function:
Type: `float | None`
The interval of the timer as a float.
Example Code
import gradio as gr
def predict(
value: float | None
):
process value from the Timer... | Behavior | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
Parameters ▼
value: float
default `= 1`
Interval in seconds between each tick.
active: bool
default `= True`
Whether the timer is active.
render: bool
default `= True`
If False, component will not render be rendered in the Blocks context. Should
be used if the inten... | Initialization | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
Shortcuts
gradio.Timer
Interface String Shortcut `"timer"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.