Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Created by Edgar Cuevas w/ Paris Smaragdis & Shrikant Venkataramani
- # © 2019 UIUC VoiceLab. All Rights Reserved
- # This file creates a basic ideal binary mask using a noise and signal processing of the same sampling rate
- import os
- import ntpath
- import scipy.signal
- import scipy.io.wavfile
- import matplotlib.pyplot as plt
- from scipy.io.wavfile import read as wavread
- from matplotlib.pylab import *
- from scipy import signal
- import numpy as np
- from matplotlib import rcParams
- import shutil
- from tkinter import filedialog
- import tkinter
- from numpy import dot, linalg, log10
- from IPython import get_ipython
- from numpy.fft import irfft, fft
- from scipy.signal import stft, istft, lfilter
- from numpy import mean, var
- import numpy as np
- from numpy.linalg import norm
- import pandas as pd
- import random
- import pdb
- import pickle
- import seaborn as sns
- import io
- # creates a given cmap to make the image look more professional for publication
- rcParams["image.cmap"] = "Greys"
- def mean_var_normalize( x):
- return (x - np.mean( x))/( np.std( x))
- def bss_eval(sep, i, sources):
- min_len = min([len(sep), len(sources[i])])
- sources = sources[:, :min_len]
- sep = sep[:min_len]
- target = sources[i]
- # Target contribution
- s_target = target * dot(target, sep.T) / dot(target, target.T)
- # Interference contribution
- pse = dot(dot(sources, sep.T), linalg.inv(dot(sources, sources.T))).T.dot(sources)
- e_interf = pse - s_target
- # Artifact contribution
- e_artif = sep - pse
- # Interference + artifacts contribution
- e_total = e_interf + e_artif
- # Computation of the log energy ratios
- sdr = 10 * log10(sum(s_target ** 2) / sum(e_total ** 2))
- sir = 10 * log10(sum(s_target ** 2) / sum(e_interf ** 2))
- sar = 10 * log10(sum((s_target + e_interf) ** 2) / sum(e_artif ** 2))
- # Done!
- return (sdr, sir, sar)
- def folderCreator(SNR):
- string_SNR = str(SNR)
- SNR_FName = string_SNR + "db"
- healthy_results_path = "~/Desktop/idbm/healthy_r"
- hoarse_results_path = "~/Desktop/idbm/hoarse_r"
- healthy_dB_path = "~/Desktop/idbm/healthy_r/" + SNR_FName
- hoarse_dB_path = "~/Desktop/idbm/hoarse_r/" + SNR_FName
- healthy_recovered_noise_path = "~/Desktop/idbm/healthy_r/" + SNR_FName + "/EstNoise"
- hoarse_recovered_noise_path = "~/Desktop/idbm/hoarse_r/" + SNR_FName + "/EstNoise"
- healthy_recovered_signal_path = (
- "~/Desktop/idbm/healthy_r/" + SNR_FName + "/EstSignal"
- )
- hoarse_recovered_signal_path = "~/Desktop/idbm/hoarse_r/" + SNR_FName + "/EstSignal"
- healthy_mix_path = "~/Desktop/idbm/healthy_r/" + SNR_FName + "/Mix"
- hoarse_mix_path = "~/Desktop/idbm/hoarse_r/" + SNR_FName + "/Mix"
- healthy_sig_path = "~/Desktop/idbm/healthy_r/" + SNR_FName + "/Sig"
- hoarse_sig_path = "~/Desktop/idbm/hoarse_r/" + SNR_FName + "/Sig"
- healthy_noise_path = "~/Desktop/idbm/healthy_r/" + SNR_FName + "/Noise"
- hoarse_noise_path = "~/Desktop/idbm/hoarse_r/" + SNR_FName + "/Noise"
- # Creates Healthy
- healthy_folder = os.path.expanduser(healthy_results_path)
- if not os.path.exists(healthy_folder):
- os.makedirs(healthy_folder)
- hoarse_folder = os.path.expanduser(hoarse_results_path)
- if not os.path.exists(hoarse_folder):
- os.makedirs(hoarse_folder)
- hoarse_folder_db = os.path.expanduser(hoarse_dB_path)
- if not os.path.exists(hoarse_folder_db):
- os.makedirs(hoarse_folder_db)
- healthy_folder_db = os.path.expanduser(healthy_dB_path)
- if not os.path.exists(healthy_folder_db):
- os.makedirs(healthy_folder_db)
- healthy_folder_db_estnoise = os.path.expanduser(healthy_recovered_noise_path)
- if not os.path.exists(healthy_folder_db_estnoise):
- os.makedirs(healthy_folder_db_estnoise)
- hoarse_folder_db_estnoise = os.path.expanduser(hoarse_recovered_noise_path)
- if not os.path.exists(hoarse_folder_db_estnoise):
- os.makedirs(hoarse_folder_db_estnoise)
- healthy_folder_db_estsignal = os.path.expanduser(healthy_recovered_signal_path)
- if not os.path.exists(healthy_folder_db_estsignal):
- os.makedirs(healthy_folder_db_estsignal)
- hoarse_folder_db_estsignal = os.path.expanduser(hoarse_recovered_signal_path)
- if not os.path.exists(hoarse_folder_db_estsignal):
- os.makedirs(hoarse_folder_db_estsignal)
- healthy_folder_mix = os.path.expanduser(healthy_mix_path)
- if not os.path.exists(healthy_folder_mix):
- os.makedirs(healthy_folder_mix)
- hoarse_folder_mix = os.path.expanduser(hoarse_mix_path)
- if not os.path.exists(hoarse_folder_mix):
- os.makedirs(hoarse_folder_mix)
- healthy_folder_sig = os.path.expanduser(healthy_sig_path)
- if not os.path.exists(healthy_folder_sig):
- os.makedirs(healthy_folder_sig)
- hoarse_folder_sig = os.path.expanduser(hoarse_sig_path)
- if not os.path.exists(hoarse_folder_sig):
- os.makedirs(hoarse_folder_sig)
- healthy_folder_noise = os.path.expanduser(healthy_noise_path)
- if not os.path.exists(healthy_folder_noise):
- os.makedirs(healthy_folder_noise)
- hoarse_folder_noise = os.path.expanduser(hoarse_noise_path)
- if not os.path.exists(hoarse_folder_noise):
- os.makedirs(hoarse_folder_noise)
- arr = [
- healthy_recovered_noise_path,
- hoarse_recovered_noise_path,
- healthy_recovered_signal_path,
- hoarse_recovered_signal_path,
- healthy_mix_path,
- hoarse_mix_path,
- healthy_sig_path,
- hoarse_sig_path,
- healthy_noise_path,
- hoarse_noise_path,
- ]
- return arr
- def getResults():
- healthy_Folder = os.path.expanduser("." + os.sep + "Healthy")
- hoarse_Folder = os.path.expanduser("." + os.sep + "Hoarse")
- noise_Folder = os.path.expanduser("." + os.sep + "Noise")
- healthy_files = [f for f in os.listdir(healthy_Folder) if f.endswith(".wav")]
- hoarse_files = [f for f in os.listdir(hoarse_Folder) if f.endswith(".wav")]
- noise_files = [f for f in os.listdir(noise_Folder) if f.endswith(".wav")]
- SDR_healthy_overall, SDR_hoarse_overall = [], []
- SIR_healthy_overall, SIR_hoarse_overall = [], []
- SAR_healthy_overall, SAR_hoarse_overall = [], []
- SNR_values = [-10,-8,-6,-4,-2,0,2,4,6,8,10]
- for SNR in SNR_values:
- string_SNR = str(SNR)
- arr = folderCreator(SNR)
- SDR_healthy, SDR_hoarse = [], []
- SIR_healthy, SIR_hoarse = [], []
- SAR_healthy, SAR_hoarse = [], []
- print('Starting for SNR: ', SNR, ' dB')
- alpha = 10 ** (-SNR/20)
- for idx in arange(40):
- #gets a random selection from the healthy_files, hoarse_files, noise_files
- healthy_selection = random.choice( healthy_files)
- hoarse_selection = random.choice( hoarse_files)
- noise_selection = random.choice (noise_files)
- #gets the names without .wav ending
- healthy_Stripped = healthy_selection.strip(".wav")
- hoarse_Stripped = hoarse_selection.strip(".wav")
- noise_Stripped = noise_selection.strip(".wav")
- sr, healthy_sig = wavread(healthy_Folder + os.sep + healthy_selection)
- sr2, hoarse_sig = wavread(hoarse_Folder + os.sep + hoarse_selection)
- sr3, noise = wavread(noise_Folder + os.sep + noise_selection)
- # Load 'em'
- healthy_sig = healthy_sig.astype( float)/32768
- hoarse_sig = hoarse_sig.astype( float)/32768
- noise = noise.astype( float)/32768
- # Trim them to the same length
- l = min( [len( healthy_sig), len( hoarse_sig), len( noise)])
- healthy_sig = healthy_sig[:l]
- hoarse_sig = hoarse_sig[:l]
- # Use random starting point for noise
- noise_start = random.choice( arange( len( noise)-l-1))
- noise = noise[int( noise_start):int(noise_start+l)]
- # Normalize to zero mean and unit variance
- healthy_sig = ( healthy_sig - np.mean( healthy_sig))/np.std( healthy_sig)
- hoarse_sig = ( hoarse_sig - np.mean( hoarse_sig))/np.std( hoarse_sig)
- noise = ( noise - np.mean( noise))/np.std( noise)
- #Naming Convention for Saving Original Noise and Signal at given dB values
- saveNoiseSTR = healthy_Stripped + "_" + hoarse_Stripped + "_healthy_orignoise.wav"
- saveNoiseSTR2 = healthy_Stripped + "_" + hoarse_Stripped + "_hoarse_orignoise.wav"
- saveSigSTR = healthy_Stripped + "_" + hoarse_Stripped + "_origsig.wav"
- saveSigSTR2 = healthy_Stripped + "_" + hoarse_Stripped + "_origsig2.wav"
- # saves the noise files used
- scipy.io.wavfile.write(
- saveNoiseSTR,
- sr,
- noise / max(abs(noise) + 0.01),
- )
- scipy.io.wavfile.write(
- saveNoiseSTR2, sr, noise / max(abs(noise) + 0.01)
- )
- # saves all the signal files used
- scipy.io.wavfile.write(
- saveSigSTR, sr, healthy_sig / max(abs(healthy_sig) + 0.01)
- )
- scipy.io.wavfile.write(
- saveSigSTR2, sr, hoarse_sig / max(abs(hoarse_sig) + 0.01)
- )
- # Make mixture
- healthy_mix = healthy_sig + alpha*noise
- hoarse_mix = hoarse_sig + alpha*noise
- # saves mixtures
- saveMixtureSTR = (
- healthy_Stripped + "_" + noise_Stripped + "_healthy_mixture.wav"
- )
- saveMixtureSTR2 = (
- hoarse_Stripped + "_" + noise_Stripped + "_hoarse_mixture.wav"
- )
- scipy.io.wavfile.write(
- saveMixtureSTR, sr, healthy_mix / max(abs(healthy_mix) + 0.01)
- )
- scipy.io.wavfile.write(
- saveMixtureSTR2, sr, hoarse_mix / max(abs(hoarse_mix) + 0.01)
- )
- # stft params
- sz = int( 2**rint( log2(sr/16)))
- hp = sz//4
- win = hanning( sz+1)[:-1]
- eps = 1e-4
- # Transform mixtures
- healthy_mix_stft = stft( healthy_mix, nperseg=sz, noverlap=sz-hp, window=win)[2]
- healthy_mix_a, healthy_mix_p = abs( healthy_mix_stft), healthy_mix_stft/( abs( healthy_mix_stft) + eps)
- hoarse_mix_stft = stft( hoarse_mix, nperseg=sz, noverlap=sz-hp, window=win)[2]
- hoarse_mix_a, hoarse_mix_p = abs( hoarse_mix_stft), hoarse_mix_stft/( abs( hoarse_mix_stft) + eps)
- # Transform ground truths
- healthy_sig_stft = stft( healthy_sig, nperseg=sz, noverlap=sz-hp, window=win)[2]
- healthy_sig_a, healthy_sig_p = abs( healthy_sig_stft), healthy_sig_stft/( abs( healthy_sig_stft) + eps)
- hoarse_sig_stft = stft( hoarse_sig, nperseg=sz, noverlap=sz-hp, window=win)[2]
- hoarse_sig_a, hoarse_sig_p = abs( hoarse_sig_stft), hoarse_sig_stft/( abs( hoarse_sig_stft) + eps)
- ########################## Possible change here.... are you doing this correctly......???????????????? ###############################
- noise_stft = stft( alpha*noise, nperseg=sz, noverlap=sz-hp, window=win)[2]
- noise_a, noise_p = abs( noise_stft), noise_stft/( abs( noise_stft) + eps)
- # Estimate Ideal Binary Masks
- healthy_mask = ( healthy_sig_a > noise_a)
- hoarse_mask = ( hoarse_sig_a > noise_a)
- # Invert 'em'
- healthy_sig_denoised = istft( healthy_mask * healthy_mix_stft, nperseg=sz, noverlap=sz-hp, window=win)[1]
- hoarse_sig_denoised = istft( hoarse_mask * hoarse_mix_stft, nperseg=sz, noverlap=sz-hp, window=win)[1]
- #Naming Convention for saved files
- saveProcessedSTR = (
- healthy_Stripped + "_" + noise_Stripped + "_healthy_processed.wav"
- )
- saveProcessedSTR2 = (
- hoarse_Stripped + "_" + noise_Stripped + "_hoarse_processed.wav"
- )
- # saves the files
- scipy.io.wavfile.write(
- saveProcessedSTR,
- sr,
- healthy_sig_denoised / max(abs(healthy_sig_denoised) + 0.01),
- )
- scipy.io.wavfile.write(
- saveProcessedSTR2,
- sr,
- hoarse_sig_denoised / max(abs(hoarse_sig_denoised) + 0.01),
- )
- # Take the shortest lenght of arr to get estimated Noise
- l2 = min(len(healthy_mix), len(healthy_sig_denoised))
- l3 = min(len(hoarse_mix), len(hoarse_sig_denoised))
- healthy_sig_length = healthy_mix[:l2]
- healthy_noise_length = healthy_sig_denoised[:l2]
- hoarse_sig_length = hoarse_mix[:l3]
- hoarse_noise_length = hoarse_sig_denoised[:l3]
- # Calculate the Estimated Noise
- recHealthy = healthy_sig_length - healthy_noise_length
- recNoise = hoarse_sig_length - hoarse_noise_length
- # Saves Estimated Noise
- saveRecNoiseSTR = (
- healthy_Stripped + "_" + noise_Stripped + "_healthy_noise_recovered.wav"
- )
- saveRecNoiseSTR2 = (
- hoarse_Stripped + "_" + noise_Stripped + "_hoarse_noise_recovered.wav"
- )
- # Saves the Estimated Noise Files
- scipy.io.wavfile.write(
- saveRecNoiseSTR, sr, recHealthy / max(abs(recHealthy) + 0.01)
- )
- scipy.io.wavfile.write(
- saveRecNoiseSTR2, sr, recNoise / max(abs(recNoise) + 0.01)
- )
- ####### Moves all of the files ####################
- saveOne = arr[0] + os.sep + saveRecNoiseSTR
- saveTwo = arr[1] + os.sep + saveRecNoiseSTR2
- saveThree = arr[2] + os.sep + saveProcessedSTR
- saveFour = arr[3] + os.sep + saveProcessedSTR2
- saveFive = arr[4] + os.sep + saveMixtureSTR
- saveSix = arr[5] + os.sep + saveMixtureSTR2
- saveSeven = arr[6] + os.sep + saveSigSTR
- saveEight = arr[7] + os.sep + saveSigSTR2
- saveNine = arr[8] + os.sep + saveNoiseSTR
- saveTen = arr[9] + os.sep + saveNoiseSTR2
- # Moves the Recovered Noise Files to Correct Place
- original = os.path.expanduser("~/Desktop/idbm/" + saveRecNoiseSTR)
- newlocation = os.path.expanduser(saveOne)
- shutil.move(original, newlocation)
- original2 = os.path.expanduser("~/Desktop/idbm/" + saveRecNoiseSTR2)
- newlocation2 = os.path.expanduser(saveTwo)
- shutil.move(original2, newlocation2)
- # Moves the Recovered Sig Files to Correct Place
- original3 = os.path.expanduser("~/Desktop/idbm/" + saveProcessedSTR)
- newlocation3 = os.path.expanduser(saveThree)
- shutil.move(original3, newlocation3)
- original4 = os.path.expanduser("~/Desktop/idbm/" + saveProcessedSTR2)
- newlocation4 = os.path.expanduser(saveFour)
- shutil.move(original4, newlocation4)
- # Moves the Mixture Files to Correct Place
- original5 = os.path.expanduser("~/Desktop/idbm/" + saveMixtureSTR)
- newlocation5 = os.path.expanduser(saveFive)
- shutil.move(original5, newlocation5)
- original6 = os.path.expanduser("~/Desktop/idbm/" + saveMixtureSTR2)
- newlocation6 = os.path.expanduser(saveSix)
- shutil.move(original6, newlocation6)
- # Moves the Sig Files to Correct Place
- original7 = os.path.expanduser("~/Desktop/idbm/" + saveSigSTR)
- newlocation7 = os.path.expanduser(saveSeven)
- shutil.move(original7, newlocation7)
- original8 = os.path.expanduser("~/Desktop/idbm/" + saveSigSTR2)
- newlocation8 = os.path.expanduser(saveEight)
- shutil.move(original8, newlocation8)
- # Moves the Noise Files to Correct Place
- original9 = os.path.expanduser("~/Desktop/idbm/" + saveNoiseSTR)
- newlocation9 = os.path.expanduser(saveNine)
- shutil.move(original9, newlocation9)
- original10 = os.path.expanduser("~/Desktop/idbm/" + saveNoiseSTR2)
- newlocation10 = os.path.expanduser(saveTen)
- shutil.move(original10, newlocation10)
- #Does all of the bss_eval calculations
- sources_healthy = [healthy_sig, alpha*noise]
- sources_healthy = np.array(sources_healthy)
- sdr_healthy, sir_healthy, sar_healthy = bss_eval(sep = healthy_sig_denoised, i=0, sources = sources_healthy)
- sources_hoarse = [hoarse_sig, alpha*noise]
- sources_hoarse = np.array(sources_hoarse)
- sdr_hoarse, sir_hoarse, sar_hoarse = bss_eval(sep = hoarse_sig_denoised, i=0, sources = sources_hoarse)
- # Store the values
- SDR_healthy.append( sdr_healthy)
- SDR_hoarse.append( sdr_hoarse)
- SIR_healthy.append( sir_healthy)
- SIR_hoarse.append( sir_hoarse)
- SAR_healthy.append( sar_healthy)
- SAR_hoarse.append( sar_hoarse)
- #Save the Values
- sigTxt = "Healthy Sound File:" + healthy_selection
- noiseTxt = "Noise Sound File:" + noise_selection
- sdrVal = "The sdr value is:" + str(sdr_healthy)
- sirVal = "The sir value is:" + str(sir_healthy)
- sarVal = "The sar value is:" + str(sar_healthy)
- txt_file_name = "Results for Healthy at " + string_SNR + "dB.txt"
- txtFile = [sigTxt, noiseTxt,sdrVal,sarVal,sirVal]
- if (idx == 0):
- text_file = open(txt_file_name, "w")
- text_file.close()
- text_file_append = open(txt_file_name, "a")
- for item in txtFile:
- text_file_append.write(item)
- text_file_append.write('\n')
- #Close text file for writing
- text_file_append.close()
- #Creates a string with the name of the folder in which files will be relocated
- sigTxt2 = "Hoarse Sound File:" + hoarse_selection
- noiseTxt2 = "Noise Sound File:" + noise_selection
- sdrVal2 = "The sdr value is:" + str(sdr_hoarse)
- sirVal2 = "The sir value is:" + str(sir_hoarse)
- sarVal2 = "The sar value is:" + str(sar_hoarse)
- txt_file_name2 = "Results for Hoarse at " + string_SNR + "dB.txt"
- txtFile2 = [sigTxt2, noiseTxt2,sdrVal2,sarVal2,sirVal2]
- if (idx == 0):
- text_file2 = open(txt_file_name2, "w")
- text_file2.close()
- text_file2_append = open(txt_file_name2, "a")
- for item2 in txtFile2:
- text_file2_append.write(item2)
- text_file2_append.write('\n')
- #Close text file for writing
- text_file2_append.close()
- print ("Overall SDR for SNR = ", SNR," dB :", np.median( SDR_healthy), np.median(SDR_hoarse))
- print ("Overall SIR for SNR = ", SNR," dB :", np.median( SIR_healthy), np.median(SIR_hoarse))
- print ("Overall SAR for SNR = ", SNR," dB :", np.median( SAR_healthy), np.median(SAR_hoarse))
- # Store to overall lists
- SDR_healthy_overall.append( SDR_healthy)
- SIR_healthy_overall.append( SIR_healthy)
- SAR_healthy_overall.append( SAR_healthy)
- SDR_hoarse_overall.append( SDR_hoarse)
- SIR_hoarse_overall.append( SIR_hoarse)
- SAR_hoarse_overall.append( SAR_hoarse)
- with open('bss_evals.pkl', 'wb') as f: # Python 3: open(..., 'wb')
- pickle.dump([SDR_healthy_overall, SIR_healthy_overall, SAR_healthy_overall, SDR_hoarse_overall, SIR_hoarse_overall, SAR_hoarse_overall], f)
- sns.palplot(sns.color_palette())
- df = pd.DataFrame(
- {"Speaker": 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] \
- + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"], \
- "SDR": SDR_healthy_overall[0] + SDR_hoarse_overall[0] + SDR_healthy_overall[1] + SDR_hoarse_overall[1] + SDR_healthy_overall[2] + SDR_hoarse_overall[2] + SDR_healthy_overall[3] + SDR_hoarse_overall[3] + \
- SDR_healthy_overall[4] + SDR_hoarse_overall[4] + SDR_healthy_overall[5] + SDR_hoarse_overall[5] + SDR_healthy_overall[6] + SDR_hoarse_overall[6] + SDR_healthy_overall[7] + SDR_hoarse_overall[7] + \
- SDR_healthy_overall[8] + SDR_hoarse_overall[8] + SDR_healthy_overall[9] + SDR_hoarse_overall[9] + SDR_healthy_overall[10] + SDR_hoarse_overall[10] , \
- "SNR": 80 * [-10] + 80 * [-8] + 80 * [-6] + 80 * [-4] + 80 * [-2] + 80 * [0] + 80 * [2] + 80 * [4] + 80 * [6] + 80 * [8] + 80 * [10]}
- )
- fig, axs = plt.subplots(nrows=3,figsize=(15,15))
- ax = sns.pointplot(x='SNR', y='SDR', hue='Speaker', data=df, ax=axs[0], estimator = np.median, dodge = .15, ci = 67)
- ax.set(ylim=(0, 26))
- ax.set(xlabel= 'SNR of mixture (dB)')
- ax.set(ylabel= 'SDR ( dB)')
- df2 = pd.DataFrame(
- {"Speaker": 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] \
- + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"], \
- "SAR": SAR_healthy_overall[0] + SAR_hoarse_overall[0] + SAR_healthy_overall[1] + SAR_hoarse_overall[1] + SAR_healthy_overall[2] + SAR_hoarse_overall[2] + SAR_healthy_overall[3] + SAR_hoarse_overall[3] + \
- SAR_healthy_overall[4] + SAR_hoarse_overall[4] + SAR_healthy_overall[5] + SAR_hoarse_overall[5] + SAR_healthy_overall[6] + SAR_hoarse_overall[6] + SAR_healthy_overall[7] + SAR_hoarse_overall[7] + \
- SAR_healthy_overall[8] + SAR_hoarse_overall[8] + SAR_healthy_overall[9] + SAR_hoarse_overall[9] + SAR_healthy_overall[10] + SAR_hoarse_overall[10] , \
- "SNR": 80 * [-10] + 80 * [-8] + 80 * [-6] + 80 * [-4] + 80 * [-2] + 80 * [0] + 80 * [2] + 80 * [4] + 80 * [6] + 80 * [8] + 80 * [10]}
- )
- # Show me
- ax2 = sns.pointplot(x='SNR', y='SAR', hue='Speaker', data=df2, ax=axs[1], estimator = np.median, dodge = .15 , ci = 67)
- ax2.set(ylim=(0, 26))
- ax2.set(xlabel= 'SNR of mixture (dB)')
- ax2.set(ylabel= 'SAR ( dB)')
- df3 = pd.DataFrame(
- {"Speaker": 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] \
- + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"] + 40 * ["Healthy"] + 40 * ["Hoarse"], \
- "SIR": SIR_healthy_overall[0] + SIR_hoarse_overall[0] + SIR_healthy_overall[1] + SIR_hoarse_overall[1] + SIR_healthy_overall[2] + SIR_hoarse_overall[2] + SIR_healthy_overall[3] + SIR_hoarse_overall[3] + \
- SIR_healthy_overall[4] + SIR_hoarse_overall[4] + SIR_healthy_overall[5] + SIR_hoarse_overall[5] + SIR_healthy_overall[6] + SIR_hoarse_overall[6] + SIR_healthy_overall[7] + SIR_hoarse_overall[7] + \
- SIR_healthy_overall[8] + SIR_hoarse_overall[8] + SIR_healthy_overall[9] + SIR_hoarse_overall[9] + SIR_healthy_overall[10] + SIR_hoarse_overall[10] , \
- "SNR": 80 * [-10] + 80 * [-8] + 80 * [-6] + 80 * [-4] + 80 * [-2] + 80 * [0] + 80 * [2] + 80 * [4] + 80 * [6] + 80 * [8] + 80 * [10]}
- )
- # Show me
- ax3 = sns.pointplot(x='SNR', y='SIR', hue='Speaker', data=df3, ax=axs[2], estimator = np.median, dodge = .15, ci = 67)
- ax3.set(ylim=(23, 29))
- ax3.set(xlabel= 'SNR of mixture (dB)')
- ax3.set(ylabel= 'SIR ( dB)')
- fig.savefig("output.eps")
- fig.savefig("output.pdf")
- getResults()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement