Surn commited on
Commit
efd6804
Β·
1 Parent(s): c707574

Register static paths, add progress, MCP support

Browse files

- Register separated/ and .separated/ as Gradio static paths for direct audio stem serving
- Update process_video_with_progress to yield progress and HTML using gr.Progress
- Add progress_callback to download_audio and separate_tracks
- Use AudioGallery._build_html and as_posix() for audio URLs
- Launch demo with mcp_server=True and allowed_paths for MCP integration
- Update docs and build instructions for new UI flow and server setup

Files changed (3) hide show
  1. CLAUDE.md +6 -1
  2. README.md +4 -1
  3. specs/build.md +7 -3
CLAUDE.md CHANGED
@@ -45,9 +45,11 @@ been indexed. Workflow:
45
  ```
46
  app.py
47
  β”œβ”€β”€ SEPARATED_DIR = Path("separated").resolve()
 
48
  β”œβ”€β”€ _footer_html() β†’ modules/version_info.versions_html()
49
  β”œβ”€β”€ process_video(video_id) β†’ MCP-exposed tool (simple, no progress)
50
- β”œβ”€β”€ process_video_with_progress(video_id) β†’ UI handler (returns html, status)
 
51
  β”‚ β”œβ”€β”€ modules.yt_audio_get_tracks.download_audio(url, id, progress_callback)
52
  β”‚ β”œβ”€β”€ modules.yt_audio_get_tracks.separate_tracks(wav, id, progress_callback)
53
  β”‚ └── AudioGallery._build_html(audio_urls, labels, columns)
@@ -86,6 +88,9 @@ emitted by `modules/yt_audio_get_tracks.py`.
86
 
87
  Button triggers `process_video_with_progress` β†’ outputs `[audio_output, progress_output]`.
88
 
 
 
 
89
  ---
90
 
91
  ## Progress Callback Pattern
 
45
  ```
46
  app.py
47
  β”œβ”€β”€ SEPARATED_DIR = Path("separated").resolve()
48
+ β”œβ”€β”€ gr.set_static_paths(paths=["separated/", ".separated/"])
49
  β”œβ”€β”€ _footer_html() β†’ modules/version_info.versions_html()
50
  β”œβ”€β”€ process_video(video_id) β†’ MCP-exposed tool (simple, no progress)
51
+ β”œβ”€β”€ process_video_with_progress(video_id) β†’ UI handler (yields html, status)
52
+ β”‚ β”œβ”€β”€ progress=gr.Progress(track_tqdm=True)
53
  β”‚ β”œβ”€β”€ modules.yt_audio_get_tracks.download_audio(url, id, progress_callback)
54
  β”‚ β”œβ”€β”€ modules.yt_audio_get_tracks.separate_tracks(wav, id, progress_callback)
55
  β”‚ └── AudioGallery._build_html(audio_urls, labels, columns)
 
88
 
89
  Button triggers `process_video_with_progress` β†’ outputs `[audio_output, progress_output]`.
90
 
91
+ The app registers `separated/` and `.separated/` as Gradio static paths so the
92
+ generated stem files can be served from the local output folder.
93
+
94
  ---
95
 
96
  ## Progress Callback Pattern
README.md CHANGED
@@ -17,6 +17,9 @@ short_description: Separate tracks from a mixed audio
17
 
18
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
19
 
20
- # Track Separate
 
 
 
21
 
22
 
 
17
 
18
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
19
 
20
+ # SeparateTracks
21
+
22
+ Download audio from YouTube, separate it into instrument stems with Demucs,
23
+ and view the results in a Gradio AudioGallery UI with MCP support.
24
 
25
 
specs/build.md CHANGED
@@ -121,11 +121,12 @@ CMD ["python", "app.py"]
121
  - `process_video(video_id)` β€” simple, MCP-exposed tool (returns HTML only)
122
  - `process_video_with_progress(video_id)` β€” UI handler (returns `(html, status_text)`)
123
  - UI: Video ID input + button β†’ Progress textbox (6 lines) β†’ AudioGallery HTML β†’ footer
 
124
  - Button wired to `process_video_with_progress` β†’ `[audio_output, progress_output]`
125
  - `demo.launch(mcp_server=True, allowed_paths=[str(SEPARATED_DIR)])`
126
- - Audio URLs: `/file={Path(p).resolve()}` format for Gradio file serving
127
- - Progress support can use `progress=gr.Progress(track_tqdm=True)` so the
128
- handler can surface interactive progress while the stem pipeline runs.
129
 
130
  ---
131
 
@@ -142,6 +143,9 @@ CMD ["python", "app.py"]
142
  - `data-initialized="false"` guard prevents double event binding on Gradio re-renders
143
  - Called in `app.py` via `AudioGallery._build_html(...)` directly (not full instantiation)
144
 
 
 
 
145
  Also created: `modules/AudioGallery.pyi` β€” type stub
146
 
147
  ---
 
121
  - `process_video(video_id)` β€” simple, MCP-exposed tool (returns HTML only)
122
  - `process_video_with_progress(video_id)` β€” UI handler (returns `(html, status_text)`)
123
  - UI: Video ID input + button β†’ Progress textbox (6 lines) β†’ AudioGallery HTML β†’ footer
124
+ - UI handler uses `progress=gr.Progress(track_tqdm=True)` for interactive progress
125
  - Button wired to `process_video_with_progress` β†’ `[audio_output, progress_output]`
126
  - `demo.launch(mcp_server=True, allowed_paths=[str(SEPARATED_DIR)])`
127
+ - Audio URLs: `/file={Path(p).as_posix()}` format for Gradio file serving
128
+ - `gr.set_static_paths(paths=["separated/", ".separated/"])` registers local
129
+ output folders for direct Gradio serving
130
 
131
  ---
132
 
 
143
  - `data-initialized="false"` guard prevents double event binding on Gradio re-renders
144
  - Called in `app.py` via `AudioGallery._build_html(...)` directly (not full instantiation)
145
 
146
+ > Note: the time display is client-side and comes from the `<audio>` element's
147
+ > metadata/runtime duration, not from the URL string.
148
+
149
  Also created: `modules/AudioGallery.pyi` β€” type stub
150
 
151
  ---