Analyze → separate → collect → mix. Shared by both YouTube and local upload pipelines after their respective source acquisition steps.
(job: Job, source: Path, job_dir: Path)
| 120 | |
| 121 | |
| 122 | def _run_common(job: Job, source: Path, job_dir: Path) -> None: |
| 123 | """Analyze → separate → collect → mix. Shared by both YouTube and local |
| 124 | upload pipelines after their respective source acquisition steps.""" |
| 125 | _check_cancel(job) |
| 126 | analyze(job, source) |
| 127 | _check_cancel(job) |
| 128 | stems_root = separate(job, source, job_dir) |
| 129 | found = collect(job, stems_root, job_dir) |
| 130 | stems_dir = job_dir / "stems" |
| 131 | job.stem_presence = compute_stem_presence(stems_dir, found) |
| 132 | # Source (100-300 MB or the local upload) is no longer needed after |
| 133 | # collect; delete it before the ffmpeg amix steps in case scratch space |
| 134 | # is tight. |
| 135 | cleanup_source(job_dir) |
| 136 | job.stems = [{"name": name, "url": f"/api/jobs/{job.id}/stems/{name}.wav"} for name in found] |
| 137 | _check_cancel(job) |
| 138 | _set(job, stage="Mixing tracks...") |
| 139 | original_path = make_original_track(job, job_dir, stems_dir) |
| 140 | if original_path is not None: |
| 141 | job.stems.insert( |
| 142 | 0, |
| 143 | { |
| 144 | "name": "original", |
| 145 | "url": f"/api/jobs/{job.id}/stems/original.wav", |
| 146 | }, |
| 147 | ) |
| 148 | _check_cancel(job) |
| 149 | mix_path = make_selected_mix(job, stems_dir, found) |
| 150 | if mix_path is not None: |
| 151 | job.mix_url = f"/api/jobs/{job.id}/stems/{mix_path.name}" |
| 152 | _check_cancel(job) |
| 153 | |
| 154 | all_stem_names = [s["name"] for s in job.stems] |
| 155 | if mix_path is not None and mix_path.stem not in all_stem_names: |
| 156 | all_stem_names.append(mix_path.stem) |
| 157 | compute_stem_peaks(stems_dir, all_stem_names) |
| 158 | |
| 159 | |
| 160 | def _run_blocking(job: Job, url: str, job_dir: Path) -> None: |
no test coverage detected