Spaces:
Running
Running
zach
commited on
Commit
·
2369fc5
1
Parent(s):
60bcef1
Set up theming
Browse files- src/app.py +4 -2
- src/theme.py +91 -0
src/app.py
CHANGED
@@ -30,6 +30,7 @@ from src.integrations import (
|
|
30 |
text_to_speech_with_hume,
|
31 |
text_to_speech_with_elevenlabs
|
32 |
)
|
|
|
33 |
from src.utils import truncate_text, validate_prompt_length
|
34 |
|
35 |
|
@@ -102,7 +103,7 @@ def run_process_prompt(prompt: str):
|
|
102 |
# Disable UI, clear previous outputs
|
103 |
yield (
|
104 |
gr.update(interactive=False, variant='secondary'), # Disable Generate Button
|
105 |
-
gr.update(value=
|
106 |
gr.update(value=None), # Clear Option 1 audio
|
107 |
gr.update(value=None), # Clear Option 2 audio
|
108 |
None, # Clear option mapping
|
@@ -165,7 +166,8 @@ def build_gradio_interface() -> gr.Blocks:
|
|
165 |
Returns:
|
166 |
gr.Blocks: The Gradio UI layout.
|
167 |
"""
|
168 |
-
|
|
|
169 |
# Title
|
170 |
gr.Markdown('# Expressive TTS Arena')
|
171 |
|
|
|
30 |
text_to_speech_with_hume,
|
31 |
text_to_speech_with_elevenlabs
|
32 |
)
|
33 |
+
from src.theme import CustomTheme
|
34 |
from src.utils import truncate_text, validate_prompt_length
|
35 |
|
36 |
|
|
|
103 |
# Disable UI, clear previous outputs
|
104 |
yield (
|
105 |
gr.update(interactive=False, variant='secondary'), # Disable Generate Button
|
106 |
+
gr.update(value="Generating..."), # Clear generated text
|
107 |
gr.update(value=None), # Clear Option 1 audio
|
108 |
gr.update(value=None), # Clear Option 2 audio
|
109 |
None, # Clear option mapping
|
|
|
166 |
Returns:
|
167 |
gr.Blocks: The Gradio UI layout.
|
168 |
"""
|
169 |
+
custom_theme = CustomTheme()
|
170 |
+
with gr.Blocks(title="Expressive TTS Arena", theme=custom_theme) as demo:
|
171 |
# Title
|
172 |
gr.Markdown('# Expressive TTS Arena')
|
173 |
|
src/theme.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from collections.abc import Iterable
|
3 |
+
from gradio.themes.base import Base
|
4 |
+
from gradio.themes.utils import colors, fonts, sizes
|
5 |
+
|
6 |
+
# TODO: Update theme styling
|
7 |
+
|
8 |
+
# Custom theme
|
9 |
+
class CustomTheme(Base):
|
10 |
+
def __init__(
|
11 |
+
self,
|
12 |
+
*,
|
13 |
+
primary_hue: colors.Color | str = colors.orange,
|
14 |
+
secondary_hue: colors.Color | str = colors.blue,
|
15 |
+
neutral_hue: colors.Color | str = colors.zinc,
|
16 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
17 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
18 |
+
text_size: sizes.Size | str = sizes.text_md,
|
19 |
+
font: fonts.Font | str | Iterable[fonts.Font | str] = (
|
20 |
+
fonts.GoogleFont("Source Sans Pro"),
|
21 |
+
"ui-sans-serif",
|
22 |
+
"system-ui",
|
23 |
+
"sans-serif",
|
24 |
+
),
|
25 |
+
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
|
26 |
+
fonts.LocalFont("IBM Plex Mono"),
|
27 |
+
"ui-monospace",
|
28 |
+
"Consolas",
|
29 |
+
"monospace",
|
30 |
+
),
|
31 |
+
):
|
32 |
+
super().__init__(
|
33 |
+
primary_hue=primary_hue,
|
34 |
+
secondary_hue=secondary_hue,
|
35 |
+
neutral_hue=neutral_hue,
|
36 |
+
spacing_size=spacing_size,
|
37 |
+
radius_size=radius_size,
|
38 |
+
text_size=text_size,
|
39 |
+
font=font,
|
40 |
+
font_mono=font_mono,
|
41 |
+
)
|
42 |
+
self.name = "custom_theme"
|
43 |
+
super().set(
|
44 |
+
# Colors
|
45 |
+
input_background_fill_dark="*neutral_800",
|
46 |
+
error_background_fill=colors.red.c50,
|
47 |
+
error_background_fill_dark="*neutral_900",
|
48 |
+
error_border_color=colors.red.c700,
|
49 |
+
error_border_color_dark=colors.red.c500,
|
50 |
+
error_icon_color=colors.red.c700,
|
51 |
+
error_icon_color_dark=colors.red.c500,
|
52 |
+
# Shadows
|
53 |
+
input_shadow_focus="0 0 0 *shadow_spread *secondary_50, *shadow_inset",
|
54 |
+
input_shadow_focus_dark="0 0 0 *shadow_spread *neutral_700, *shadow_inset",
|
55 |
+
# Button borders
|
56 |
+
button_border_width="0px",
|
57 |
+
input_border_width="1px",
|
58 |
+
input_background_fill="white",
|
59 |
+
# Gradients
|
60 |
+
stat_background_fill="linear-gradient(to right, *primary_400, *primary_200)",
|
61 |
+
stat_background_fill_dark="linear-gradient(to right, *primary_400, *primary_600)",
|
62 |
+
checkbox_label_background_fill="*background_fill_primary",
|
63 |
+
checkbox_label_background_fill_dark="*neutral_800",
|
64 |
+
checkbox_label_background_fill_hover="*background_fill_secondary",
|
65 |
+
checkbox_label_background_fill_hover_dark="*checkbox_label_background_fill",
|
66 |
+
# Primary Button
|
67 |
+
button_primary_background_fill="*primary_500",
|
68 |
+
button_primary_background_fill_dark="*primary_600",
|
69 |
+
button_primary_background_fill_hover="*primary_600",
|
70 |
+
button_primary_background_fill_hover_dark="*primary_700",
|
71 |
+
button_primary_text_color="white",
|
72 |
+
button_primary_text_color_dark="white",
|
73 |
+
# Secondary Button
|
74 |
+
button_secondary_background_fill="*neutral_200",
|
75 |
+
button_secondary_background_fill_dark="*neutral_600",
|
76 |
+
button_secondary_background_fill_hover="*neutral_300",
|
77 |
+
button_secondary_background_fill_hover_dark="*neutral_700",
|
78 |
+
button_secondary_text_color="black",
|
79 |
+
button_secondary_text_color_dark="white",
|
80 |
+
# Cancel Button
|
81 |
+
button_cancel_background_fill=colors.red.c500,
|
82 |
+
button_cancel_background_fill_dark=colors.red.c700,
|
83 |
+
button_cancel_background_fill_hover=colors.red.c600,
|
84 |
+
button_cancel_background_fill_hover_dark=colors.red.c800,
|
85 |
+
button_cancel_text_color="white",
|
86 |
+
button_cancel_text_color_dark="white",
|
87 |
+
button_cancel_text_color_hover="white",
|
88 |
+
button_cancel_text_color_hover_dark="white",
|
89 |
+
# Other
|
90 |
+
border_color_accent_subdued="*primary_200",
|
91 |
+
)
|