Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Bug fix for repitching & tempo automix errors #593

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ torchaudio>=0.8,<2.1
tqdm
treetable
soundfile>=0.10.3;sys_platform=="win32"
librosa @ git+https://github.com/librosa/librosa.git
12 changes: 9 additions & 3 deletions tools/automix.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ def find_candidate(spec_ref, catalog, pitch_match=True):
def get_part(spec, source, dt, dp):
"""Apply given delta of tempo and delta of pitch to a stem."""
wav = spec.track[source]
if dt or dp:
wav = repitch(wav, dp, dt * 100, samplerate=SR, voice=source == 3)
if dt != 0 or dp != 0: # Check if there's any change to apply
# Ensure 'dt' is a scalar if it's an array
if isinstance(dt, np.ndarray) and dt.size == 1:
dt = float(dt.item()) # Convert numpy array to Python scalar
# Convert tempo change from relative change (e.g., -0.12 for 88%) to percentage change expected by `repitch`
tempo_percentage_change = dt * 100 # Convert to percentage (e.g., -12 for 88% speed)
# Apply pitch and tempo changes
wav = repitch(wav, dp, tempo_percentage_change, voice=source == 3, samplerate=SR)
# Adjust onsets according to new tempo
spec = spec._replace(onsets=spec.onsets / (1 + dt))
return wav, spec


def build_track(ref_index, catalog):
"""Given the reference track index and a catalog of track, builds
a completely new track. One of the source at random from the ref track will
Expand Down
Loading