<jupyter_start><jupyter_text>load a random sample from DSD100 Test<jupyter_code>samples = create_samples('Dev')
test_sample = samples[0]
print(test_sample['name'])
sound, sr = librosa.load(test_sample['mix'], sr=44100, mono=True)
stft = librosa.stft(sound, n_fft=2048, hop_length=512, win_length=2048)
phase = np.angle(stft)<jupyter_output><empty_output><jupyter_text>Load model<jupyter_code>sorted(os.listdir(os.path.join(os.pardir, 'saved_model')))
# load model
model_path = os.path.join(os.pardir, 'saved_model', 'conv_denoising_unet?time=20200223_0347.h5')
model = tf.keras.models.load_model(model_path)
pred = model.predict(wav_to_spectrogram_clips(test_sample['mix']))
pred[2].shape<jupyter_output><empty_output><jupyter_text>Separation evaluation  Listen to the result<jupyter_code>def play(audio):
    track, sr = librosa.load(audio, sr=44100)
    return track
    
def play_separated_track(separated_audio, phase):
    separated_track= np.squeeze(separated_audio, axis=-1)
    spectrogram = np.concatenate(separated_track, axis=1)
    phase = phase[tuple(map(slice, spectrogram.shape))]
    reconstructed_track = librosa.istft(spectrogram * np.exp(1j * phase), hop_length=512, win_length=2048)
    return reconstructed_track<jupyter_output><empty_output><jupyter_text>Vocal track<jupyter_code>track = play(test_sample['vocals'])
ipd.Audio(track, rate=44100)
separated_track = play_separated_track(pred[0], phase)
ipd.Audio(separated_track, rate=44100)
librosa.output.write_wav('./separated_vocals.wav', separated_track, sr=44100, norm=True)<jupyter_output><empty_output><jupyter_text>Bass track<jupyter_code>track = play(test_sample['bass'])
ipd.Audio(track, rate=44100)
separated_track = play_separated_track(pred[1])
ipd.Audio(separated_track, rate=44100)<jupyter_output><empty_output><jupyter_text>Drums track<jupyter_code>track = play(test_sample['drums'])
ipd.Audio(track, rate=44100)
separated_track = play_separated_track(pred[2])
ipd.Audio(separated_track, rate=44100)<jupyter_output><empty_output><jupyter_text>other track<jupyter_code>track = play(test_sample['other'])
ipd.Audio(track, rate=44100)
separated_track = play_separated_track(pred[3])
ipd.Audio(separated_track, rate=44100)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13384064458370637, 'fraction_numerical': 0.043867502238137866, 'mean_word_length': 10.287878787878787, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '664840', 'license': 'Apache-2.0', 'n_tokens_mistral': 927, 'n_tokens_neox': 841, 'n_words': 105, 'path': 'notebooks/audio_separator_eval.ipynb', 'repo_name': 'Yossarian0916/audio_source_separator', 'size': '2234'}