Closed jurihock closed 2 weeks ago
Finally, I adapted the external_usage.py
example to suit my needs and use soundfile
paired with resampy
, to load and save the audio files.
Something like this:
import numpy as np
import resampy
import soundfile
from df.enhance import enhance, init_df
model, state, _ = init_df()
x, sr = soundfile.read('x.wav', always_2d=True)
x = x if sr == state.sr() else resampy.resample(x, sr, state.sr())
sr = state.sr()
x = x.astype(np.float32).T
x = torch.from_numpy(x)
y = enhance(model, state, x)
y = y.detach().cpu().numpy()
y = np.squeeze(y.T)
soundfile.write('y.wav', y, sr)
Steps to reproduce:
Error log: