owiedotch commited on
Commit
15e2eb9
·
verified ·
1 Parent(s): be47bd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -22,14 +22,11 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
22
  yield None, stream_log("Starting separation process...")
23
  yield None, stream_log(f"Loading audio file: {audio_file}")
24
 
25
- # Load the audio file with the correct samplerate
26
- wav, sr = load_track(audio_file, samplerate=separator.samplerate, channels=2)
27
 
28
- # Check the number of channels and adjust if necessary
29
- if wav.shape[0] == 1:
30
- wav = wav.repeat(2, 1) # If mono, duplicate to stereo
31
- elif wav.shape[0] > 2:
32
- wav = wav[:2] # If more than 2 channels, keep only the first two
33
 
34
  ref = wav.mean(0)
35
  wav = (wav - ref.view(1, -1)).to(device)
 
22
  yield None, stream_log("Starting separation process...")
23
  yield None, stream_log(f"Loading audio file: {audio_file}")
24
 
25
+ # Load the audio file with the correct parameters
26
+ wav = load_track(audio_file, device, audio_channels=2, samplerate=separator.samplerate)
27
 
28
+ # The load_track function already handles channel conversion and resampling,
29
+ # so we can remove the channel adjustment code here.
 
 
 
30
 
31
  ref = wav.mean(0)
32
  wav = (wav - ref.view(1, -1)).to(device)