Skip to content

Commit 45ecb64

Browse files
refactor: preserve source extension in archive name
1 parent c440915 commit 45ecb64

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pnpm dev
8181

8282
Open `http://localhost:5173`, choose a local audio file and the required model files from `data/onnx-lean/`, then run separation. Audio and models stay in the browser.
8383

84-
When separation finishes, the app automatically downloads all generated stems as `<input>.stems.zip`. Individual stem previews and WAV downloads remain available in the results.
84+
When separation finishes, the app automatically downloads all generated stems as a source-named archive such as `song_wav.stems.zip`. Individual stem previews and WAV downloads remain available in the results.
8585

8686
Build the static app with:
8787

packages/app/e2e/separate.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test("separates a clip fully client-side", async ({ page }) => {
3434
});
3535
await expect(page.getByTestId("timing-summary")).toContainText("Inference");
3636
const download = await downloadPromise;
37-
expect(download.suggestedFilename()).toBe("sine-2s.stems.zip");
37+
expect(download.suggestedFilename()).toBe("sine-2s_wav.stems.zip");
3838

3939
const stems = page.locator("#stems > div");
4040
await expect(stems).toHaveCount(2);
@@ -44,5 +44,5 @@ test("separates a clip fully client-side", async ({ page }) => {
4444
await expect(page.locator("#stems a")).toHaveCount(2);
4545
await expect(
4646
page.getByRole("link", { name: "Download ZIP" }),
47-
).toHaveAttribute("download", "sine-2s.stems.zip");
47+
).toHaveAttribute("download", "sine-2s_wav.stems.zip");
4848
});

packages/app/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
createStemArchive,
1717
downloadBlob,
1818
orderStemFiles,
19-
stemArchiveFilename,
19+
toStemArchiveFilename,
2020
} from "./lib/audio/stem-archive";
2121
import { encodeWavF32 } from "./lib/audio/wav";
2222
import { separateInWorker } from "./lib/audio/worker-client";
@@ -166,7 +166,7 @@ export function App() {
166166
const durationMs = performance.now() - started;
167167
const archiveBlob = await createStemArchive(nextOutputs);
168168
const archive = {
169-
name: stemArchiveFilename(decodedAudio.name),
169+
name: toStemArchiveFilename(decodedAudio.name),
170170
url: URL.createObjectURL(archiveBlob),
171171
};
172172
outputCleanupRef.current.push(() => URL.revokeObjectURL(archive.url));

packages/app/src/lib/audio/stem-archive.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ export function orderStemFiles<T extends { name: string }>(
2121
return [...stems].sort((a, b) => rank(a.name) - rank(b.name));
2222
}
2323

24-
export function stemArchiveFilename(inputFilename: string): string {
25-
const extensionIndex = inputFilename.lastIndexOf(".");
26-
const basename =
27-
extensionIndex > 0 ? inputFilename.slice(0, extensionIndex) : inputFilename;
28-
return `${basename || "stems"}.stems.zip`;
24+
export function toStemArchiveFilename(inputFilename: string): string {
25+
const basename = inputFilename.replaceAll(".", "_");
26+
return `${basename || "demucs"}.stems.zip`;
2927
}
3028

3129
export async function createStemArchive(stems: StemFile[]): Promise<Blob> {

0 commit comments

Comments
 (0)