feat: clone and import python_speech_features

and add a mfcc func
This commit is contained in:
Skudalen 2021-06-28 10:57:08 +02:00
parent e7087b04c7
commit 452a591837
7 changed files with 31 additions and 18 deletions

BIN
.DS_Store vendored

Binary file not shown.

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
Exp20201205_2myo_hard**
Exp20201205_2myo_soft**
Documents
python_speech_features
python_speech_features**

View File

@ -1,7 +1,6 @@
import pandas as pd
from pathlib import Path
import numpy as np
from pandas.core.frame import DataFrame
class Data_container:

View File

@ -1,5 +1,7 @@
from Handle_emg_data import *
from Signal_prep import *
import matplotlib.pyplot as plt
from matplotlib import cm
# PLOT FUNCTIONS:
@ -9,7 +11,7 @@ def plot_df(df:DataFrame):
plt.show()
# Plots ndarrays after transformations
def plot_arrays(N, N_name, y, y_name):
def plot_array(N, y):
plt.plot(N, np.abs(y))
plt.show()
@ -25,6 +27,12 @@ def plot_compare_two_df(df_old, old_name, df_new, new_name):
axis[1].set_title(new_name)
plt.show()
def plot_mfcc(mfcc_data):
fig, ax = plt.subplots()
mfcc_data= np.swapaxes(mfcc_data, 0 ,1)
cax = ax.imshow(mfcc_data, interpolation='nearest', cmap=cm.coolwarm, origin='lower')
ax.set_title('MFCC')
plt.show()
# DATA FUNCTIONS:
@ -59,6 +67,17 @@ def denoice_dataset(handler:Handler.CSV_handler, subject_nr, which_arm, round, e
return df_new
# CASE FUNTIONS
def compare_with_wavelet(data_frame):
N_trans, cA, cD = wavelet_db4(data_frame)
data_frame_freq = make_df_from_xandy(N_trans, cA, 1)
cA_filt, cD_filt = soft_threshold_filter(cA, cD)
data_frame_freq_filt = make_df_from_xandy(N_trans, cD_filt, 1)
plot_compare_two_df(data_frame_freq, 'Original data', data_frame_freq_filt, 'Analyzed data')
# MAIN:
@ -68,13 +87,9 @@ def main():
load_data(csv_handler, 'hard')
data_frame = get_data(csv_handler, 1, 'left', 1, 1)
N_trans, cA, cD = wavelet_db4(data_frame)
data_frame_freq = make_df_from_xandy(N_trans, cA, 1)
cA_filt, cD_filt = soft_threshold_filter(cA, cD)
data_frame_freq_filt = make_df_from_xandy(N_trans, cD_filt, 1)
plot_compare_two_df(data_frame_freq, 'Original data', data_frame_freq_filt, 'Analyzed data')
N, y_mfcc = mfcc(data_frame)
plt.plot(y_mfcc)
plt.show()
return None

View File

@ -1,12 +1,11 @@
import numpy as np
import matplotlib.pyplot as plt
import pandas
from pandas.core.frame import DataFrame
from scipy.fft import fft, fftfreq
import pywt
import pyhton_speech_features as psf
#from scipy.signal import wavelets
#import pyyawt
#from pyhton_speech_features.base import mfcc
import sys
sys.path.insert(0, '/Users/Markus/Prosjekter git/Slovakia 2021/python_speech_features/python_speech_features')
from python_speech_features.python_speech_features import *
import Handle_emg_data as Handler
@ -78,9 +77,9 @@ def cepstrum(df:DataFrame):
return None
'''
def mfcc(df:DataFrame):
N = get_xory_from_df('x', df)
y = get_xory_from_df('y', df)
spf.mfcc(y, )
'''
return N, base.mfcc(y, SAMPLE_RATE)