Skip to content

Split any YouTube song into stems

TypeScript

fix: address review — shared instrument guard, export path, cpu fallback, oom match

Anton Sychev74d63ab82e24
diff --git a/python/roformer.py b/python/roformer.py
index 52e1bdd..3f58b23 100644
--- a/python/roformer.py
+++ b/python/roformer.py
@@ -317,7 +317,10 @@ def main():
model = load_model(ckpt_path, device, use_half)
except Exception as e2:
fail(f"vocals engine load failed on cpu: {e2}")
- est = separate(model, mix, device, use_half, on_progress)
+ try:
+ est = separate(model, mix, device, use_half, on_progress)
+ except Exception as e2:
+ fail(f"vocals separation failed on cpu: {e2}")
else:
fail(f"separation failed: {e}")
diff --git a/src/main/library.ts b/src/main/library.ts
index b13b505..16607fa 100644
--- a/src/main/library.ts
+++ b/src/main/library.ts
@@ -71,6 +71,8 @@ export function clearLibrary(): void {
export function sanitizeName(name: string): string {
const clean = name.replace(/[\\/:*?"<>|]/g, '-').trim()
+ // joined under the export root: '..' would land in its parent
+ if (clean === '.' || clean === '..') return 'stems'
return clean.length > 0 ? clean.slice(0, 120) : 'stems'
}
diff --git a/src/main/pipeline.ts b/src/main/pipeline.ts
index 3026ee0..4dc05b0 100644
--- a/src/main/pipeline.ts
+++ b/src/main/pipeline.ts
@@ -692,7 +692,7 @@ function runProcess(
never ends */
if (
(code === null && signal === 'SIGKILL' && !detail) ||
- /out of memory|cannot allocate|std::bad_alloc|insufficient memory/i.test(detail)
+ /(?:cuda|mps backend) out of memory|can(?:no|')t allocate memory|std::bad_alloc/i.test(detail)
) {
reject(
new Error(
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index cf78675..4506a16 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -203,6 +203,12 @@ export default function App(): React.ReactElement {
return
}
const { model, stems } = startOpts.current
+ /* checked before either branch: an empty pick means "default 4-stem
+ split" downstream, so a link would start a split nobody asked for */
+ if (stems.length === 0) {
+ setNotice('Pick at least one instrument first')
+ return
+ }
const files = Array.from(dt.files)
if (files.length === 0) {
const link = (dt.getData('text/uri-list') || '').split(/[\r\n]/)[0]
@@ -230,10 +236,6 @@ export default function App(): React.ReactElement {
)
return
}
- if (stems.length === 0) {
- setNotice('Pick at least one instrument first')
- return
- }
if (skipped.length > 0) setNotice(`Skipped ${skipped.join(', ')} — not audio`)
paths.forEach((path, i) => {
void startLocal(path, model, stems, i === 0)