Kokoro-FastAPI/ui/lib/components/output.py

44 lines
1.2 KiB
Python
Raw Normal View History

from typing import Tuple
2025-01-01 21:50:41 -07:00
import gradio as gr
from .. import files
2025-01-01 21:50:41 -07:00
def create_output_column() -> Tuple[gr.Column, dict]:
"""Create the output column with audio player and file list."""
with gr.Column(scale=1) as col:
gr.Markdown("### Latest Output")
2025-01-01 21:50:41 -07:00
audio_output = gr.Audio(label="Generated Speech", type="filepath")
gr.Markdown("### Generated Files")
output_files = gr.Dropdown(
label="Previous Outputs",
choices=files.list_output_files(),
value=None,
2025-01-12 21:33:23 -07:00
allow_custom_value=True,
)
2025-01-01 21:50:41 -07:00
play_btn = gr.Button("▶️ Play Selected", size="sm")
2025-01-01 21:50:41 -07:00
selected_audio = gr.Audio(
2025-01-01 21:50:41 -07:00
label="Selected Output", type="filepath", visible=False
)
clear_outputs = gr.Button(
"⚠️ Delete All Previously Generated Output Audio 🗑️",
size="sm",
variant="secondary",
)
2025-01-01 21:50:41 -07:00
components = {
"audio_output": audio_output,
"output_files": output_files,
"play_btn": play_btn,
2025-01-01 21:50:00 -07:00
"selected_audio": selected_audio,
2025-01-01 21:50:41 -07:00
"clear_outputs": clear_outputs,
}
2025-01-01 21:50:41 -07:00
return col, components
2025-01-12 21:33:23 -07:00
return col, components