Spaces:
Runtime error
Runtime error
update app
Browse files
app.py
CHANGED
|
@@ -6,6 +6,78 @@ import os
|
|
| 6 |
import tempfile
|
| 7 |
import spaces
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
try:
|
| 10 |
from sam_audio import SAMAudio, SAMAudioProcessor
|
| 11 |
except ImportError as e:
|
|
@@ -200,7 +272,7 @@ css = """
|
|
| 200 |
|
| 201 |
with gr.Blocks() as demo:
|
| 202 |
gr.Markdown("# **SAM-Audio-Demo**", elem_id="main-title")
|
| 203 |
-
gr.Markdown("Segment and isolate specific sounds from audio files using natural language descriptions, powered by [SAM-Audio-Large](https://huggingface.co/facebook/sam-audio-large).")
|
| 204 |
|
| 205 |
with gr.Column(elem_id="col-container"):
|
| 206 |
with gr.Row():
|
|
@@ -208,7 +280,7 @@ with gr.Blocks() as demo:
|
|
| 208 |
input_file = gr.Audio(label="Input Audio", type="filepath")
|
| 209 |
text_prompt = gr.Textbox(label="Sound to Isolate", placeholder="e.g., 'A man speaking', 'Bird chirping'")
|
| 210 |
|
| 211 |
-
with gr.Accordion("Advanced Settings", open=
|
| 212 |
chunk_duration_slider = gr.Slider(
|
| 213 |
minimum=10, maximum=60, value=30, step=5,
|
| 214 |
label="Chunk Duration (seconds)",
|
|
@@ -239,8 +311,4 @@ with gr.Blocks() as demo:
|
|
| 239 |
)
|
| 240 |
|
| 241 |
if __name__ == "__main__":
|
| 242 |
-
demo.launch(theme=
|
| 243 |
-
primary_hue="blue",
|
| 244 |
-
secondary_hue="indigo",
|
| 245 |
-
neutral_hue="slate",
|
| 246 |
-
), css=css, mcp_server=True, ssr_mode=False)
|
|
|
|
| 6 |
import tempfile
|
| 7 |
import spaces
|
| 8 |
|
| 9 |
+
from typing import Iterable
|
| 10 |
+
from gradio.themes import Soft
|
| 11 |
+
from gradio.themes.utils import colors, fonts, sizes
|
| 12 |
+
|
| 13 |
+
colors.orange_red = colors.Color(
|
| 14 |
+
name="orange_red",
|
| 15 |
+
c50="#FFF0E5",
|
| 16 |
+
c100="#FFE0CC",
|
| 17 |
+
c200="#FFC299",
|
| 18 |
+
c300="#FFA366",
|
| 19 |
+
c400="#FF8533",
|
| 20 |
+
c500="#FF4500",
|
| 21 |
+
c600="#E63E00",
|
| 22 |
+
c700="#CC3700",
|
| 23 |
+
c800="#B33000",
|
| 24 |
+
c900="#992900",
|
| 25 |
+
c950="#802200",
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
class OrangeRedTheme(Soft):
|
| 29 |
+
def __init__(
|
| 30 |
+
self,
|
| 31 |
+
*,
|
| 32 |
+
primary_hue: colors.Color | str = colors.gray,
|
| 33 |
+
secondary_hue: colors.Color | str = colors.orange_red, # Use the new color
|
| 34 |
+
neutral_hue: colors.Color | str = colors.slate,
|
| 35 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
| 36 |
+
font: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 37 |
+
fonts.GoogleFont("Outfit"), "Arial", "sans-serif",
|
| 38 |
+
),
|
| 39 |
+
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 40 |
+
fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace",
|
| 41 |
+
),
|
| 42 |
+
):
|
| 43 |
+
super().__init__(
|
| 44 |
+
primary_hue=primary_hue,
|
| 45 |
+
secondary_hue=secondary_hue,
|
| 46 |
+
neutral_hue=neutral_hue,
|
| 47 |
+
text_size=text_size,
|
| 48 |
+
font=font,
|
| 49 |
+
font_mono=font_mono,
|
| 50 |
+
)
|
| 51 |
+
super().set(
|
| 52 |
+
background_fill_primary="*primary_50",
|
| 53 |
+
background_fill_primary_dark="*primary_900",
|
| 54 |
+
body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
|
| 55 |
+
body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
|
| 56 |
+
button_primary_text_color="white",
|
| 57 |
+
button_primary_text_color_hover="white",
|
| 58 |
+
button_primary_background_fill="linear-gradient(90deg, *secondary_500, *secondary_600)",
|
| 59 |
+
button_primary_background_fill_hover="linear-gradient(90deg, *secondary_600, *secondary_700)",
|
| 60 |
+
button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_700)",
|
| 61 |
+
button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
|
| 62 |
+
button_secondary_text_color="black",
|
| 63 |
+
button_secondary_text_color_hover="white",
|
| 64 |
+
button_secondary_background_fill="linear-gradient(90deg, *primary_300, *primary_300)",
|
| 65 |
+
button_secondary_background_fill_hover="linear-gradient(90deg, *primary_400, *primary_400)",
|
| 66 |
+
button_secondary_background_fill_dark="linear-gradient(90deg, *primary_500, *primary_600)",
|
| 67 |
+
button_secondary_background_fill_hover_dark="linear-gradient(90deg, *primary_500, *primary_500)",
|
| 68 |
+
slider_color="*secondary_500",
|
| 69 |
+
slider_color_dark="*secondary_600",
|
| 70 |
+
block_title_text_weight="600",
|
| 71 |
+
block_border_width="3px",
|
| 72 |
+
block_shadow="*shadow_drop_lg",
|
| 73 |
+
button_primary_shadow="*shadow_drop_lg",
|
| 74 |
+
button_large_padding="11px",
|
| 75 |
+
color_accent_soft="*primary_100",
|
| 76 |
+
block_label_background_fill="*primary_200",
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
orange_red_theme = OrangeRedTheme()
|
| 80 |
+
|
| 81 |
try:
|
| 82 |
from sam_audio import SAMAudio, SAMAudioProcessor
|
| 83 |
except ImportError as e:
|
|
|
|
| 272 |
|
| 273 |
with gr.Blocks() as demo:
|
| 274 |
gr.Markdown("# **SAM-Audio-Demo**", elem_id="main-title")
|
| 275 |
+
gr.Markdown("Segment and isolate specific music/sounds from audio files using natural language descriptions, powered by [SAM-Audio-Large](https://huggingface.co/facebook/sam-audio-large).")
|
| 276 |
|
| 277 |
with gr.Column(elem_id="col-container"):
|
| 278 |
with gr.Row():
|
|
|
|
| 280 |
input_file = gr.Audio(label="Input Audio", type="filepath")
|
| 281 |
text_prompt = gr.Textbox(label="Sound to Isolate", placeholder="e.g., 'A man speaking', 'Bird chirping'")
|
| 282 |
|
| 283 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 284 |
chunk_duration_slider = gr.Slider(
|
| 285 |
minimum=10, maximum=60, value=30, step=5,
|
| 286 |
label="Chunk Duration (seconds)",
|
|
|
|
| 311 |
)
|
| 312 |
|
| 313 |
if __name__ == "__main__":
|
| 314 |
+
demo.launch(theme=orange_red_theme, css=css, mcp_server=True, ssr_mode=False)
|
|
|
|
|
|
|
|
|
|
|
|