<jupyter_start><jupyter_text>Simple augmentation to create synthetic abnormal![image.png](attachment:image.png)<jupyter_code>BASE_FOLDER =  r'../../'
%run -i ..\..\utility\feature_extractor\JupyterLoad_feature_extractor.py
def mel(s,sr, c= 0):
    wmf = memory_wave_file()
    wmf.filepath=file_path
    wmf.srate=sr
    wmf.channel=s
    fe_mel = feature_extractor_mel(BASE_FOLDER,'mel1')
    fe_mel.set_hyperparamter(n_mels=80, n_fft=1024, channel=c)
    fe_mel.create_from_wav(wmf)
    fe_mel.plot()

def psd(s,sr, c= 0):
    wmf = memory_wave_file()
    wmf.filepath=file_path
    wmf.srate=sr
    wmf.channel=s
    fe_psd = feature_extractor_welchPSD(BASE_FOLDER,'psd1')
    fe_psd.set_hyperparamter(nperseg=512, nfft=1024, channel=c) 
    fe_psd.create_from_wav(wmf) 
    fe_psd.plot()

def test(file_path):
    ch, sr = librosa.load(os.path.abspath(BASE_FOLDER+file_path), sr=None, mono=False)
    noisy_signal = ch

    wmf = memory_wave_file()
    wmf.filepath = file_path
    wmf.channel = noisy_signal
    wmf.srate = sr
    wmf.length = len(noisy_signal)

    wmf_r = create_augmenter(wmf)
    mel(wmf.channel)
    plt.show()
    mel(wmf_r.channel)
    plt.show()
    return wmf_r
file_path = r'\dataset\6dB\fan\id_02\normal\00000004.wav'
wmf_r = test(file_path)
mel(wmf_r.channel,5)
file_path = r'\dataset\6dB\pump\id_02\normal\00000004.wav'
file_path = r'\dataset\6dB\fan\id_02\normal\00000004.wav'
wmf_r = test(file_path)
file_path = r'\dataset\6dB\valve\id_02\normal\00000004.wav'
wmf_r = test(file_path)
file_path = r'\dataset\6dB\slider\id_02\normal\00000004.wav'
wmf_r = test(file_path)
from librosa.util import normalize as norm
def test(file_path):
    ch, sr = librosa.load(os.path.abspath(BASE_FOLDER+file_path), sr=None, mono=False)
    noisy_signal = ch

    wmf = memory_wave_file()
    wmf.filepath = file_path
    wmf.channel = noisy_signal
    wmf.srate = sr
    wmf.length = len(noisy_signal)

    wmf_r = create_augmenter(wmf)
    psd(norm(wmf.channel),sr)
    #plt.show()
    psd(norm(wmf_r.channel),sr)
    plt.grid()
    plt.legend(['norm.','aug.'])
    return wmf_r

file_path = r'\dataset\6dB\slider\id_02\normal\00000004.wav'
plt.figure(figsize=(16,9))
for i in range(4):
    plt.subplot(2, 2, i+1)
    wmf_r = test(file_path)
    plt.title(f'rand augment {i+1}')
    
    

plt.tight_layout()
plt.savefig(f'augment_PSD_slider.png', transparent=False, dpi=300)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.138442521631644, 'fraction_numerical': 0.03914297486608982, 'mean_word_length': 4.0269151138716355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '564846', 'license': 'MIT', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1037, 'n_words': 141, 'path': 'feature_extraction_diagrams/A30_Augmentation/Simple_Augmenter.ipynb', 'repo_name': 'BA-HanseML/NF_Prj_MIMII_Dataset', 'size': '2427'}