Custom Components GalleryNEW

Explore

New to Gradio? Start here: Getting Started

See the Release History

TabbedInterface

gradio.TabbedInterface(interface_list, ยทยทยท)

Description

A TabbedInterface is created by providing a list of Interfaces or Blocks, each of which gets rendered in a separate tab. Only the components from the Interface/Blocks will be rendered in the tab. Certain high-level attributes of the Blocks (e.g. custom css, js, and head attributes) will not be loaded.

Initialization

Parameter Description
interface_list

list[Interface]

required

A list of Interfaces (or Blocks) to be rendered in the tabs.

tab_names

list[str] | None

default: None

A list of tab names. If None, the tab names will be "Tab 1", "Tab 2", etc.

title

str | None

default: None

The tab title to display when this demo is opened in a browser window.

theme

Theme | str | None

default: None

A Theme object or a string representing a theme. If a string, will look for a built-in theme with that name (e.g. "soft" or "default"), or will attempt to load a theme from the Hugging Face Hub (e.g. "gradio/monochrome"). If None, will use the Default theme.

analytics_enabled

bool | None

default: None

Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable or default to True.

css

str | None

default: None

Custom css as a string or path to a css file. This css will be included in the demo webpage.

js

str | None

default: None

Custom js or path to js file to run when demo is first loaded. This javascript will be included in the demo webpage.

head

str | None

default: None

Custom html to insert into the head of the demo webpage. This can be used to add custom meta tags, scripts, stylesheets, etc. to the page.

Demos

import gradio as gr

tts_examples = [
    "I love learning machine learning",
    "How do you do?",
]

tts_demo = gr.load(
    "huggingface/facebook/fastspeech2-en-ljspeech",
    title=None,
    examples=tts_examples,
    description="Give me something to say!",
)

stt_demo = gr.load(
    "huggingface/facebook/wav2vec2-base-960h",
    title=None,
    inputs=gr.Microphone(type="filepath"),
    description="Let me try to guess what you're saying!",
)

demo = gr.TabbedInterface([tts_demo, stt_demo], ["Text-to-speech", "Speech-to-text"])

if __name__ == "__main__":
    demo.launch()