提交 7f9bda0c 编写于 作者: xuchaoxin1375's avatar xuchaoxin1375

- fix some bugs.

- certain adjustments to the project code.
上级 e4e1fb4d
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
*.npy *.npy
*.nyc *.nyc
*.csv *.csv
*.fts *.fts
\ No newline at end of file *.h5
\ No newline at end of file
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
- 我猜测可能时机器太久没有关机了(平时我都是休眠),导致系统出现了一些错误 - 我猜测可能时机器太久没有关机了(平时我都是休眠),导致系统出现了一些错误
- 机器发生错误是很有可能的,就比如学校图书馆的刷脸系统,验证通过平时屏幕显示绿色,然而最近通过显示的也是红色 - 机器发生错误是很有可能的,就比如学校图书馆的刷脸系统,`验证成功`平时的话屏幕显示绿色提醒,然而最近`验证成功`显示的也是红色
- 而在早期的windows7上,有时候从休眠中回复直接会失败 - 而在早期的windows7上,有时候从休眠中回复直接会失败
- 然后我重启机器,发现任务栏多出了个搜索框,系统更新了没有重启可能也造成了一些影响 - 然后我重启机器,发现任务栏多出了个搜索框,系统更新了没有重启可能也造成了一些影响
...@@ -831,6 +831,43 @@ print("Accuracy:", clf.score(X_test, y_test)) ...@@ -831,6 +831,43 @@ print("Accuracy:", clf.score(X_test, y_test))
在使用MLPRegressor时,需要根据具体的数据集和任务需求,选择合适的参数来构建模型。同时,还可以通过交叉验证等技术来评估模型的性能和调整参数,以获得更好的预测结果。需要注意的是,MLPRegressor算法对于数据集的特征缩放和标准化非常敏感,因此在使用MLPRegressor时需要对数据进行预处理。 在使用MLPRegressor时,需要根据具体的数据集和任务需求,选择合适的参数来构建模型。同时,还可以通过交叉验证等技术来评估模型的性能和调整参数,以获得更好的预测结果。需要注意的是,MLPRegressor算法对于数据集的特征缩放和标准化非常敏感,因此在使用MLPRegressor时需要对数据进行预处理。
#### BaggingClassifier
A Bagging classifier.
A Bagging classifier is an ensemble meta-estimator that fits base classifiers each on random subsets of the original dataset and then aggregate their individual predictions (either by voting or by averaging) to form a final prediction. Such a meta-estimator can typically be used as a way to reduce the variance of a black-box estimator (e.g., a decision tree), by introducing randomization into its construction procedure and then making an ensemble out of it.
This algorithm encompasses several works from the literature. When random subsets of the dataset are drawn as random subsets of the samples, then this algorithm is known as Pasting [[1\]](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html#rb1846455d0e5-1). If samples are drawn with replacement, then the method is known as Bagging [[2\]](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html#rb1846455d0e5-2). When random subsets of the dataset are drawn as random subsets of the features, then the method is known as Random Subspaces [[3\]](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html#rb1846455d0e5-3). Finally, when base estimators are built on subsets of both samples and features, then the method is known as Random Patches [[4\]](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html#rb1846455d0e5-4).
Bagging分类器是一种元估计器集成方法,它在原始数据集的随机子集上分别拟合基分类器,然后聚合它们的个体预测结果(通过投票或平均)以形成最终预测。这种元估计器通常可以用作一种降低黑盒估计器(例如决策树)方差的方法,通过将随机化引入其构建过程,然后将其组合起来。
此算法包括文献中的几项工作。当随机抽取数据集的子集作为样本的随机子集时,此算法称为Pasting [1]。如果使用放回抽样,则该方法称为Bagging [2]。当随机抽取数据集的子集作为特征的随机子集时,该方法称为随机子空间方法[3]。最后,当基估计器基于样本和特征的子集构建时,该方法称为Random Patches [4]。
In ensemble algorithms, bagging methods form a class of algorithms which build several instances of a black-box estimator on random subsets of the original training set and then aggregate their individual predictions to form a final prediction. These methods are used as a way to reduce the variance of a base estimator (e.g., a decision tree), by introducing randomization into its construction procedure and then making an ensemble out of it. In many cases, bagging methods constitute a very simple way to improve with respect to a single model, without making it necessary to adapt the underlying base algorithm. As they provide a way to reduce overfitting, bagging methods work best with strong and complex models (e.g., fully developed decision trees), in contrast with boosting methods which usually work best with weak models (e.g., shallow decision trees).
Bagging methods come in many flavours but mostly differ from each other by the way they draw random subsets of the training set:
> - When random subsets of the dataset are drawn as random subsets of the samples, then this algorithm is known as Pasting [[B1999\]](https://scikit-learn.org/stable/modules/ensemble.html#b1999).
> - When samples are drawn with replacement, then the method is known as Bagging [[B1996\]](https://scikit-learn.org/stable/modules/ensemble.html#b1996).
> - When random subsets of the dataset are drawn as random subsets of the features, then the method is known as Random Subspaces [[H1998\]](https://scikit-learn.org/stable/modules/ensemble.html#h1998).
> - Finally, when base estimators are built on subsets of both samples and features, then the method is known as Random Patches [[LG2012\]](https://scikit-learn.org/stable/modules/ensemble.html#lg2012).
In scikit-learn, bagging methods are offered as a unified [`BaggingClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html#sklearn.ensemble.BaggingClassifier) meta-estimator (resp. [`BaggingRegressor`](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingRegressor.html#sklearn.ensemble.BaggingRegressor)), taking as input a user-specified estimator along with parameters specifying the strategy to draw random subsets. In particular, `max_samples` and `max_features` control the size of the subsets (in terms of samples and features), while `bootstrap` and `bootstrap_features` control whether samples and features are drawn with or without replacement. When using a subset of the available samples the generalization accuracy can be estimated with the out-of-bag samples by setting `oob_score=True`. As an example, the snippet below illustrates how to instantiate a bagging ensemble of `KNeighborsClassifier` estimators, each built on random subsets of 50% of the samples and 50% of the features.
在集成算法中,bagging方法是一类算法,它在原始训练集的随机子集上构建多个黑盒估计器实例,然后聚合它们的个体预测结果以形成最终预测。这些方法通过将随机化引入其构建过程,并将其组合起来,以降低基本估计器(例如决策树)的方差。在许多情况下,bagging方法是一种非常简单的改进单个模型的方法,而无需调整底层基础算法。由于它们提供了一种减少过拟合的方法,因此bagging方法适用于强大而复杂的模型(例如完全发展的决策树),而提升方法通常适用于弱模型(例如浅层决策树)。
Bagging方法有许多变种,但它们主要通过绘制训练集的随机子集的方式而不同:
当随机抽取数据集的子集作为样本的随机子集时,此算法称为Pasting [B1999]。
如果使用放回抽样,则该方法称为Bagging [B1996]。
当随机抽取数据集的子集作为特征的随机子集时,该方法称为随机子空间方法[ H1998]。
最后,当基估计器基于样本和特征的子集构建时,该方法称为Random Patches [LG2012]。
在scikit-learn中,Bagging方法提供了一个统一的BaggingClassifier元估计器(resp. BaggingRegressor),以用户指定的估计器为输入,并指定绘制随机子集的策略的参数。特别地,max_samples和max_features控制子集的大小(以样本和特征为单位),而bootstrap和bootstrap_features控制是否使用有放回或无放回的方式来抽取样本和特征。当使用可用样本的子集时,可以通过设置oob_score=True来估计外部样本的泛化精度。例如,下面的代码段说明如何实例化一个KNeighborsClassifier估计器的bagging集合,每个估计器都是在50%的样本和50%的特征的随机子集上构建的。
#### BaggingRegressor #### BaggingRegressor
BaggingRegressor是一种基于袋装法(Bagging)的回归模型,常用于机器学习中。 BaggingRegressor是一种基于袋装法(Bagging)的回归模型,常用于机器学习中。
...@@ -995,11 +1032,13 @@ SVR(Support Vector Regression)是一种基于支持向量机(SVM)的回 ...@@ -995,11 +1032,13 @@ SVR(Support Vector Regression)是一种基于支持向量机(SVM)的回
- 使用大纲阅读一个大文件是好办法 - 使用大纲阅读一个大文件是好办法
- 对于没有封装在函数或者类中的代码,可以设置`fold level`折叠至level 2来快速把握代码结构 - 对于没有封装在函数或者类中的代码,可以设置`fold level`折叠至level 2来快速把握代码结构
## 部分实验结果 # 部分实验结果
### 跨库识别 ## 跨库识别
#### angry&sad ####
### angry&sad@emodb-ravdess
- `train_emodb_AS.csv+test_ravdess_AS.csv` - `train_emodb_AS.csv+test_ravdess_AS.csv`
...@@ -1053,6 +1092,62 @@ SVR(Support Vector Regression)是一种基于支持向量机(SVM)的回 ...@@ -1053,6 +1092,62 @@ SVR(Support Vector Regression)是一种基于支持向量机(SVM)的回
test_score=0.770935960591133 test_score=0.770935960591133
``` ```
### ravdess-emodb
```bash
(d:\condaPythonEnvs\tf2.10) PS D:\repos\CCSER\SER> py "d:\repos\CCSER\SER\recognizer\basic.py"
@{model}
partition='train'
D:\repos\CCSER\SER\meta_files\train_ravdess_AS.csv @🎈{meta_file}
[I] Loading audio file paths and its corresponding labels...
meta_file存在D:\repos\CCSER\SER\meta_files\train_ravdess_AS.csv文件!
检查特征文件D:\repos\CCSER\SER\features\ravdess_mfcc_AS_1216.npy是否存在...
self.e_config=['angry', 'sad']
self.f_config=['mfcc']
npy文件不存在,尝试创建...
{} @{self.feature_transforms}🎈
True @{save_obj}
Extracting features for partition:: 100%|███████████████████████████████████████████████████████████| 1216/1216 [00:19<00:00, 63.43it/s]
fts参数key合法
🎈🎈🎈特征提取
(1216, 40) @{feature.shape}
[Info] Adding train samples
partition='test'
D:\repos\CCSER\SER\meta_files\test_emodb_AS.csv @🎈{meta_file}
[I] Loading audio file paths and its corresponding labels...
meta_file存在D:\repos\CCSER\SER\meta_files\test_emodb_AS.csv文件!
检查特征文件D:\repos\CCSER\SER\features\emodb_mfcc_AS_38.npy是否存在...
self.e_config=['angry', 'sad']
self.f_config=['mfcc']
特征矩阵文件(.npy)已经存在,直接导入:loading...
(38, 40) @{feature.shape}
[Info] Adding test samples
[I] Data loaded
self.ae=<audio.extractor.AudioExtractor object at 0x0000028D91CE85E0>
self.ae.pca=None🎈
Evaluating <SVC>: 0%| | 0/5 [00:00<?, ?it/s]@{model}
[I] SVC with 0.7105263157894737 test accuracy
Evaluating <RandomForestClassifier>: 20%|████████████▊ | 1/5 [00:05<00:23, 5.80s/it]@{model}
Evaluating <BaggingClassifier>: 100%|█████████████████████████████████████████████████████████████████████| 5/5 [00:14<00:00, 2.99s/it]
[🎈] Best model : RandomForestClassifier with 97.368% test accuracy
train_score=0.9868421052631579verbose=0 precision recall f1-score support
angry 1.00 0.92 0.96 24
sad 0.88 1.00 0.93 14
accuracy 0.95 38
macro avg 0.94 0.96 0.94 38
weighted avg 0.95 0.95 0.95 38 RandomForestClassifier
test_score=0.9473684210526315
(1216, 40) (1216,) 🎈
n_splits=5
cv_score=0.9508196721311475
(d:\condaPythonEnvs\tf2.10) PS D:\repos\CCSER\SER>
```
#### angry&happy&sad #### angry&happy&sad
......
...@@ -118,7 +118,7 @@ def get_algos_elements_list(ava_algorithms=ava_algorithms): ...@@ -118,7 +118,7 @@ def get_algos_elements_list(ava_algorithms=ava_algorithms):
algo.title(), algo.title(),
"algorithm", "algorithm",
key=f"{algo}", key=f"{algo}",
default=(i == 1), default=(i == 0),
enable_events=True, enable_events=True,
) )
) )
...@@ -360,7 +360,7 @@ def get_file_choose_layout(): ...@@ -360,7 +360,7 @@ def get_file_choose_layout():
# ], # ],
# [ # [
sg.B( sg.B(
"recognize it", "Recognize it",
key="recognize it", key="recognize it",
tooltip=lang["recognize_the_audio_emotion"], tooltip=lang["recognize_the_audio_emotion"],
), ),
...@@ -482,8 +482,7 @@ def get_logging_viewer_layout(): ...@@ -482,8 +482,7 @@ def get_logging_viewer_layout():
def get_analyzer_layout(): def get_analyzer_layout():
analyzer_layout = ( analyzer_log_printer_layout = [
[
[bt.h2("Anything printed will display here!")], [bt.h2("Anything printed will display here!")],
[ [
sg.Multiline( sg.Multiline(
...@@ -499,9 +498,17 @@ def get_analyzer_layout(): ...@@ -499,9 +498,17 @@ def get_analyzer_layout():
) )
], ],
] ]
+ dv.layout
+ q.query_layout # analyzer_layout = (
) # analyzer_log_printer
# + dv.layout
# + q.query_layout
# )
analyzer_layout = [
*analyzer_log_printer_layout,
*dv.layout,
*q.query_layout,
]
return analyzer_layout return analyzer_layout
...@@ -663,12 +670,12 @@ def get_algo_layout(): ...@@ -663,12 +670,12 @@ def get_algo_layout():
def get_e_config_layout(): def get_e_config_layout():
emotion_config_checboxes_layout = [ emotion_config_checboxes_layout = [
[ [
sg.Checkbox("angry", key="angry", default=True, enable_events=True), sg.Checkbox("angry", key="angry", default=False, enable_events=True),
sg.Checkbox("happy", key="happy", enable_events=True), sg.Checkbox("happy", key="happy", default=True, enable_events=True),
sg.Checkbox("neutral", key="neutral", default=True, enable_events=True), sg.Checkbox("neutral", key="neutral", default=True, enable_events=True),
sg.Checkbox("ps", key="ps", enable_events=True), sg.Checkbox("ps", key="ps", enable_events=True),
sg.Checkbox("sad", key="sad", default=True, enable_events=True), sg.Checkbox("sad", key="sad", default=True, enable_events=True),
sg.Checkbox("others", key="others", default=True, enable_events=True), sg.Checkbox("others", key="others", default=False, enable_events=True),
] ]
] ]
...@@ -692,34 +699,6 @@ def get_e_config_layout(): ...@@ -692,34 +699,6 @@ def get_e_config_layout():
return e_config_layout return e_config_layout
tooltip_pca_components = """
PCA components
Number of components to keep. if n_components is not set all components are kept:
n_components == min(n_samples, n_features)
If n_components == 'mle' and svd_solver == 'full', Minka’s MLE is used to guess the dimension. Use of n_components == 'mle' will interpret svd_solver == 'auto' as svd_solver == 'full'.
If 0 < n_components < 1 and svd_solver == 'full', select the number of components such that the amount of variance that needs to be explained is greater than the percentage specified by n_components.
If svd_solver == 'arpack', the number of components must be strictly less than the minimum of n_features and n_samples.
Hence, the None case results in:
n_components == min(n_samples, n_features) - 1
"""
tooltip_pca_svd_solver = """
If auto :
The solver is selected by a default policy based on X.shape and n_components: if the input data is larger than 500x500 and the number of components to extract is lower than 80% of the smallest dimension of the data, then the more efficient ‘randomized’ method is enabled. Otherwise the exact full SVD is computed and optionally truncated afterwards.
If full :
run exact full SVD calling the standard LAPACK solver via scipy.linalg.svd and select the components by postprocessing
If arpack :
run SVD truncated to n_components calling ARPACK solver via scipy.sparse.linalg.svds. It requires strictly 0 < n_components < min(X.shape)
If randomized :
run randomized SVD by the method of Halko et al.
"""
def get_f_config_layout(): def get_f_config_layout():
...@@ -760,16 +739,17 @@ def get_f_transform_layout(): ...@@ -760,16 +739,17 @@ def get_f_transform_layout():
), ),
], ],
[ [
sg.T('n_components:',tooltip="input the number of components to keep."),
sg.Input( sg.Input(
key=pca_components_key, key=pca_components_key,
default_text="35", default_text="None",
tooltip=tooltip_pca_components, tooltip=bt.pca_components_tooltip,
enable_events=True, enable_events=True,
), ),
sg.Combo( sg.Combo(
values=ava_svd_solver, values=ava_svd_solver,
default_value="auto", default_value="auto",
tooltip=tooltip_pca_svd_solver, tooltip=bt.pca_svd_solver_tooltip,
enable_events=True, enable_events=True,
key=pca_svd_solver_key, key=pca_svd_solver_key,
), ),
...@@ -791,7 +771,7 @@ def get_f_transform_layout(): ...@@ -791,7 +771,7 @@ def get_f_transform_layout():
], ],
) )
f_transform_layout = [ f_transform_layout = [
[bt.h2(lang["feature_transfomr_config"])], [bt.h2(lang["feature_transform_config"])],
[f_transform_frame_layout], [f_transform_frame_layout],
] ]
return f_transform_layout return f_transform_layout
......
...@@ -33,6 +33,52 @@ logo = """ ...@@ -33,6 +33,52 @@ logo = """
""" """
pca_components_tooltip = """
PCA components
Number of components to keep. if n_components is not set all
components are kept:
n_components == min(n_samples, n_features)
If n_components == 'mle' and svd_solver == 'full', Minka’s MLE
is used to guess the dimension. Use of n_components == 'mle' will
interpret svd_solver == 'auto' as svd_solver == 'full'.
If 0 < n_components < 1 and svd_solver == 'full', select
the number of components such that the amount of variance that
needs to be explained is greater than the percentage specified
by n_components.
If svd_solver == 'arpack', the number of components must
be strictly less than the minimum of n_features and n_samples.
Hence, the None case results in:
n_components == min(n_samples, n_features) - 1
"""
pca_svd_solver_tooltip = """
If auto :
The solver is selected by a default policy based on X.shape and
n_components:
if the input data is larger than 500x500 and the number of components
to extract is lower than 80% of the smallest dimension of the data,
then the more efficient ‘randomized’ method is enabled. Otherwise
the exact full SVD is computed and optionally truncated afterwards.
If full :
run exact full SVD calling the standard LAPACK solver via scipy.
linalg.svd and select the components by postprocessing
If arpack :
run SVD truncated to n_components calling ARPACK solver via
scipy.sparse.linalg.svds. It requires strictly
0 < n_components < min(X.shape)
If randomized :
run randomized SVD by the method of Halko et al.
"""
db_introduction = """ db_introduction = """
## SpeechDatabases ## SpeechDatabases
......
...@@ -14,7 +14,7 @@ emotion_counts = df["emotion"].value_counts() ...@@ -14,7 +14,7 @@ emotion_counts = df["emotion"].value_counts()
# 创建窗口布局 # 创建窗口布局
layout = [ layout = [
[sg.Text("情感成分分析图表")], [sg.Text("Emotional Component Analysis")],
[sg.Canvas(key="-CANVAS-")], [sg.Canvas(key="-CANVAS-")],
[sg.Button("generate pie graph")], [sg.Button("generate pie graph")],
] ]
......
##!/usr/bin/env python ##
from matplotlib.ticker import NullFormatter # useful for `logit` scale # from matplotlib.ticker import NullFormatter # useful for `logit` scale
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import PySimpleGUI as sg import PySimpleGUI as sg
import matplotlib import matplotlib
matplotlib.use('TkAgg')
matplotlib.use("TkAgg")
""" """
Demonstrates one way of embedding Matplotlib figures into a PySimpleGUI window. Demonstrates one way of embedding Matplotlib figures into a PySimpleGUI window.
...@@ -23,82 +25,41 @@ Basic steps are: ...@@ -23,82 +25,41 @@ Basic steps are:
# ------------------------------- PASTE YOUR MATPLOTLIB CODE HERE ------------------------------- # ------------------------------- PASTE YOUR MATPLOTLIB CODE HERE -------------------------------
#
# # Goal is to have your plot contained in the variable "fig"
#
# # Fixing random state for reproducibility
# np.random.seed(19680801)
#
# # make up some data in the interval ]0, 1[
# y = np.random.normal(loc=0.5, scale=0.4, size=1000)
# y = y[(y > 0) & (y < 1)]
# y.sort()
# x = np.arange(len(y))
#
# # plot with various axes scales
# plt.figure(1)
#
# # linear
# plt.subplot(221)
# plt.plot(x, y)
# plt.yscale('linear')
# plt.title('linear')
# plt.grid(True)
#
# # log
# plt.subplot(222)
# plt.plot(x, y)
# plt.yscale('log')
# plt.title('log')
# plt.grid(True)
#
# # symmetric log
# plt.subplot(223)
# plt.plot(x, y - y.mean())
# plt.yscale('symlog', linthreshy=0.01)
# plt.title('symlog')
# plt.grid(True)
#
# # logit
# plt.subplot(224)
# plt.plot(x, y)
# plt.yscale('logit')
# plt.title('logit')
# plt.grid(True)
# plt.gca().yaxis.set_minor_formatter(NullFormatter())
# plt.subplots_adjust(top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25,
# wspace=0.35)
# fig = plt.gcf()
#
fig = matplotlib.figure.Figure(figsize=(5, 4), dpi=100) fig = matplotlib.figure.Figure(figsize=(5, 4), dpi=100)
t = np.arange(0, 3, .01) t = np.arange(0, 3, 0.01)
fig.add_subplot(111).plot(t, 2 * np.sin(2 * np.pi * t)) fig.add_subplot(111).plot(t, 2 * np.sin(2 * np.pi * t))
# ------------------------------- END OF YOUR MATPLOTLIB CODE ------------------------------- # ------------------------------- END OF YOUR MATPLOTLIB CODE -------------------------------
# ------------------------------- Beginning of Matplotlib helper code ----------------------- # ------------------------------- Beginning of Matplotlib helper code -----------------------
def draw_figure(canvas, figure): def draw_figure(canvas, figure):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas) figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw() figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1) figure_canvas_agg.get_tk_widget().pack(side="top", fill="both", expand=1)
return figure_canvas_agg return figure_canvas_agg
# ------------------------------- Beginning of GUI CODE ------------------------------- # ------------------------------- Beginning of GUI CODE -------------------------------
# define the window layout # define the window layout
layout = [[sg.Text('Plot test')], layout = [[sg.Text("Plot test")], [sg.Canvas(key="-CANVAS-")], [sg.Button("Ok")]]
[sg.Canvas(key='-CANVAS-')],
[sg.Button('Ok')]]
# create the form and show it without the plot # create the form and show it without the plot
window = sg.Window('Demo Application - Embedding Matplotlib In PySimpleGUI', layout, finalize=True, element_justification='center', font='Helvetica 18') window = sg.Window(
"Demo Application - Embedding Matplotlib In PySimpleGUI",
layout,
finalize=True,
element_justification="center",
font="Helvetica 18",
)
# add the plot to the window # add the plot to the window
fig_canvas_agg = draw_figure(window['-CANVAS-'].TKCanvas, fig) fig_canvas_agg = draw_figure(window["-CANVAS-"].TKCanvas, fig)
# display the window
event, values = window.read() event, values = window.read()
window.close() window.close()
...@@ -106,7 +106,10 @@ def get_audios_regex( ...@@ -106,7 +106,10 @@ def get_audios_regex(
else: else:
path = path.absolute() path = path.absolute()
# 对路径进行正则过滤 # 对路径进行正则过滤
#todo 对括号的识别有问题(得益于模块化,可以直接在这个模块内启动图形界面进行调试)
if filter_regex: if filter_regex:
if verbose:
print('filter_regex:> ', filter_regex)
s = re.search(filter_regex, str(path), re.IGNORECASE) s = re.search(filter_regex, str(path), re.IGNORECASE)
if s: if s:
filtered_audios.append(path) filtered_audios.append(path)
...@@ -226,7 +229,7 @@ audio_viewer_layout = [ ...@@ -226,7 +229,7 @@ audio_viewer_layout = [
], ],
[ [
sg.B(filter_audios_key, tooltip="click to manual refresh the files listbox"), sg.B(filter_audios_key, tooltip="click to manual refresh the files listbox"),
sg.Button(ufg.close), # sg.Button(ufg.close),
], ],
[sg.Text(f"{len_default_folder_file_list} files", key="num_files_text")], [sg.Text(f"{len_default_folder_file_list} files", key="num_files_text")],
[ [
......
...@@ -32,7 +32,7 @@ class TableShow(): ...@@ -32,7 +32,7 @@ class TableShow():
# background_color="lightblue", # background_color="lightblue",
auto_size_columns=True, auto_size_columns=True,
justification="center", justification="center",
num_rows=min(25, len(self.data_rows)), num_rows=min(15, len(self.data_rows)),#每次最多显示15条数据
expand_x=True, expand_x=True,
expand_y=True, expand_y=True,
) )
...@@ -43,7 +43,7 @@ class TableShow(): ...@@ -43,7 +43,7 @@ class TableShow():
] ]
def run(self): def run(self):
window = sg.Window("result table", self.layout,resizable=True,size=(500,400)) window = sg.Window("result table", self.layout,resizable=True,size=(500,500))
# 事件循环 # 事件循环
while True: while True:
event, values = window.read() event, values = window.read()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"welcome_message": "Welcome to My App!", "welcome_message": "Welcome to My App!",
"choose_emotion_config": "Please select an emotional combination for testing: recommended combinations are AS, HNS, AHNS, AHNPS. \nNote that there is a difference between 'surprise' and 'pleasantSurprise' in the SAVEE dataset, \nso the AHNPS combination is not recommended for use on SAVEE.", "choose_emotion_config": "Please select an emotional combination for testing: recommended combinations are AS, HNS, AHNS, AHNPS. \nNote that there is a difference between 'surprise' and 'pleasantSurprise' in the SAVEE dataset, \nso the AHNPS combination is not recommended for use on SAVEE.",
"choose_feature_config": "Please choose one or more features", "choose_feature_config": "Please choose one or more features",
"feature_transfomr_config":"feature transfomer config", "feature_transform_config":"feature transformer config",
"choose_algorithm": "Choose an algorithm for testing", "choose_algorithm": "Choose an algorithm for testing",
"choose_audio": "Please select an audio sample file to recognize its emotion.", "choose_audio": "Please select an audio sample file to recognize its emotion.",
"recognize_the_audio_emotion": "Recognize the emotion of the selected audio file.", "recognize_the_audio_emotion": "Recognize the emotion of the selected audio file.",
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
"welcome_title": "𝒲ℯ𝓁𝒸ℴ𝓂ℯ 𝓉ℴ ℯ𝓍𝓅ℯ𝓇𝒾ℯ𝓃𝒸ℯ 𝒞𝒞𝒮ℰℛ 𝒞𝓁𝒾ℯ𝓃𝓉!", "welcome_title": "𝒲ℯ𝓁𝒸ℴ𝓂ℯ 𝓉ℴ ℯ𝓍𝓅ℯ𝓇𝒾ℯ𝓃𝒸ℯ 𝒞𝒞𝒮ℰℛ 𝒞𝓁𝒾ℯ𝓃𝓉!",
"result_training":"result of model training:", "result_training":"result of model training:",
"train_result_title":"Train Result", "train_result_title":"Train Result",
"result_frame":"Emotion Of Select File(Predict Result)" "result_frame":"Emotion Of Select File(Predict Result)",
"recognize_it":"Recognize it"
} }
\ No newline at end of file
...@@ -134,7 +134,8 @@ class UserAuthenticatorGUI: ...@@ -134,7 +134,8 @@ class UserAuthenticatorGUI:
key="confirm_password", password_char="*", enable_events=True key="confirm_password", password_char="*", enable_events=True
), ),
], ],
[sg.Submit(button_text="Register"), sg.Cancel(button_text="Cancel")], # sg.Submit默认绑定了enter快捷键,为了避免误操作,需要谨慎使用
[sg.Submit(button_text="Register",bind_return_key=False), sg.Cancel(button_text="Cancel")],
] ]
# 定义登录Tab页布局 # 定义登录Tab页布局
...@@ -152,7 +153,7 @@ class UserAuthenticatorGUI: ...@@ -152,7 +153,7 @@ class UserAuthenticatorGUI:
key=passowrd_login_key, password_char="*", enable_events=True key=passowrd_login_key, password_char="*", enable_events=True
), ),
], ],
[sg.Submit(button_text="Login"), sg.Cancel(button_text="Cancel")], [sg.Submit(button_text="Login",bind_return_key=False), sg.Cancel(button_text="Cancel")],
] ]
return register_layout, login_layout return register_layout, login_layout
......
##
import os import os
from collections import defaultdict
import sys import sys
import ipdb from collections import defaultdict
from joblib import load from pathlib import Path
import ipdb
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import tqdm import tqdm
from joblib import load
from audio.create_meta import create_csv_by_metaname
from config.EF import AHNPS, HNS, AHNPS_dict, HNS_dict, e_config_def, f_config_def
import config.MetaPath as mp import config.MetaPath as mp
from config.MetaPath import (
create_tag_name,
features_dir,
get_first_letters,
train_emodb_csv,
validate_partition,
ava_dbs,
ava_fts_params
)
from audio.core import extract_feature_of_audio from audio.core import extract_feature_of_audio
from audio.create_meta import create_csv_by_metaname
from config.EF import (AHNPS, HNS, AHNPS_dict, HNS_dict, e_config_def,
f_config_def)
from config.MetaPath import (ava_dbs, ava_fts_params, create_tag_name, emodb,
features_dir, get_first_letters, meta_dir,
project_dir, train_emodb_csv, validate_partition)
# from pathlib import Path # from pathlib import Path
Series = pd.Series Series = pd.Series
...@@ -100,6 +98,11 @@ class AudioExtractor: ...@@ -100,6 +98,11 @@ class AudioExtractor:
self.test_features = [] self.test_features = []
# 使用字典打包 # 使用字典打包
self.pca = None self.pca = None
def pathlike_to_list(self, meta_paths):
if isinstance(meta_paths, str) or isinstance(meta_paths,Path):
# print(f"cast the '{meta_paths}' to [str]")
meta_paths = [meta_paths]
return meta_paths
def get_partition_features(self, partition) -> np.ndarray: def get_partition_features(self, partition) -> np.ndarray:
"""将包含若干个二维ndarray的列表vstack成1个二维ndarray """将包含若干个二维ndarray的列表vstack成1个二维ndarray
...@@ -134,14 +137,19 @@ class AudioExtractor: ...@@ -134,14 +137,19 @@ class AudioExtractor:
def load_metadata(self, meta_files): def load_metadata(self, meta_files):
""" """
从meta_files(文件)中读取语料库各条语音的信息; 从给定meta_files(文件)路径中读取语料库各条语音的信息;
如果需要读取的meta_files不存在,那么尝试解析meta_files(如果meta_files参数是一个符合可解析规范的字符串)
这种情况下会调用create_meta模块中的create_csv_by_metaname函数进行meta文件构造
Read metadata from a file & Extract and loads features of audio files Read metadata from a file & Extract meta if according meta_files and loads features of audio files
Parameters Parameters
---------- ----------
meta_files : list[str]|str meta_files : list[str]|str
需要读取的meta文件 需要读取的meta文件
Return
-
从meta中读取的信息:包括各语音文件的路径和情感标签
""" """
# empty dataframe # empty dataframe
...@@ -157,12 +165,13 @@ class AudioExtractor: ...@@ -157,12 +165,13 @@ class AudioExtractor:
# print("meta_files:", meta_files) # print("meta_files:", meta_files)
# print("type(meta_files)", type(meta_files)) # print("type(meta_files)", type(meta_files))
if isinstance(meta_files, str):
meta_files = [meta_files] meta_files = self.pathlike_to_list(meta_files)
for meta_file in meta_files: for meta_file in meta_files:
if not os.path.exists(meta_file): if not os.path.exists(meta_file):
# create_csv_by_meta_name # create_csv_by_meta_name
print(f"{meta_file} does not exist,creating...😂") print(f"{meta_file} does not exist,creating...😂")
create_csv_by_metaname(meta_file, shuffle=self.shuffle) create_csv_by_metaname(meta_file, shuffle=self.shuffle)
else: else:
print(f"meta_file存在{meta_file}文件!") print(f"meta_file存在{meta_file}文件!")
...@@ -326,7 +335,7 @@ class AudioExtractor: ...@@ -326,7 +335,7 @@ class AudioExtractor:
# 尝试计算语料库的名字和情感配置名字 # 尝试计算语料库的名字和情感配置名字
db = self.fields_parse(meta_path) db = self.fields_parse(meta_path)
# 特征保存的目录检查(不存在则创建之)
if not os.path.isdir(self.features_dir): if not os.path.isdir(self.features_dir):
os.mkdir(self.features_dir) os.mkdir(self.features_dir)
...@@ -378,6 +387,10 @@ class AudioExtractor: ...@@ -378,6 +387,10 @@ class AudioExtractor:
return features, audio_paths, emotions return features, audio_paths, emotions
def get_features_file_path(self, partition, db, n_samples,ext=""): def get_features_file_path(self, partition, db, n_samples,ext=""):
fts=self.feature_transforms
if fts is None:
self.feature_transforms = {}
features_file_name = create_tag_name( features_file_name = create_tag_name(
db=db, db=db,
partition=partition, # 建议保存特征文件时,这个字段置空即可 partition=partition, # 建议保存特征文件时,这个字段置空即可
...@@ -474,8 +487,6 @@ class AudioExtractor: ...@@ -474,8 +487,6 @@ class AudioExtractor:
# 考虑特征预处理 # 考虑特征预处理
from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import StandardScaler
# X为特征矩阵,y为标签 # X为特征矩阵,y为标签
fts = self.feature_transforms fts = self.feature_transforms
...@@ -508,16 +519,20 @@ class AudioExtractor: ...@@ -508,16 +519,20 @@ class AudioExtractor:
n_components = pca_params_dict.get("n_components") n_components = pca_params_dict.get("n_components")
if n_components == "None":
# pca_params_dict["n_components"] = None if n_components=='mle':
n_components=None
elif n_components=='mle':
pass pass
else: elif isinstance(n_components, int):
pass
elif n_components and n_components.isdigit():
# if n_components.isdigit(): # if n_components.isdigit():
# int()函数自带类型错误检测,有非法输入会自动抛出错误,所以这里直接使用,而不去手动检测输入的合法性 # int()函数自带类型错误检测,有非法输入会自动抛出错误,所以这里直接使用,而不去手动检测输入的合法性
# pca_params_dict['n_components'] = int(n_components) # pca_params_dict['n_components'] = int(n_components)
n_components=int(n_components) n_components=int(n_components)
# elif n_components == "None":
else:
# pca_params_dict["n_components"] = None
n_components=None
# 将检验&处理后的n_components写入到pca字典中 # 将检验&处理后的n_components写入到pca字典中
pca_params_dict['n_components']=n_components pca_params_dict['n_components']=n_components
...@@ -573,21 +588,23 @@ class AudioExtractor: ...@@ -573,21 +588,23 @@ class AudioExtractor:
return features return features
def extract_update(self, partition="", meta_paths="", verbose=1): def extract_update(self, partition="", meta_paths="", verbose=1):
"""特征提取和self属性更新维护 """
根据meta_paths进行特征提取任务
提取完特征后对相关self属性更新维护
多次调用将执行增量提取,根据partition的取值,将每次的提取结果增量更新self的相应属性集 多次调用将执行增量提取,根据partition的取值,将每次的提取结果增量更新self的相应属性集
Parameters Parameters
---------- ----------
partition : str partition : str
"train"|"test" "train"|"test"
meta_files : list[str]|str meta_paths : list[str]|str
_description_ 需要提取特征的meta文件路径
""" """
if not meta_paths: if not meta_paths:
raise ValueError("meta_files cannot be empty") raise ValueError("meta_files cannot be empty")
# return meta_files # return meta_files
if isinstance(meta_paths, str): meta_paths = self.pathlike_to_list(meta_paths)
# print(f"cast the '{meta_paths}' to [str]")
meta_paths = [meta_paths]
# 执行特征提取 # 执行特征提取
for meta_file in meta_paths: for meta_file in meta_paths:
...@@ -614,6 +631,7 @@ class AudioExtractor: ...@@ -614,6 +631,7 @@ class AudioExtractor:
features=features, features=features,
) )
def load_data_preprocessing(self, meta_files=None, partition="", shuffle=False): def load_data_preprocessing(self, meta_files=None, partition="", shuffle=False):
"""将特征提取和属性设置以及打乱和平衡操作打包处理 """将特征提取和属性设置以及打乱和平衡操作打包处理
AE对象在如数据集后可选的数据处理操作(balance&shuffle) AE对象在如数据集后可选的数据处理操作(balance&shuffle)
...@@ -883,21 +901,22 @@ def load_data_from_meta( ...@@ -883,21 +901,22 @@ def load_data_from_meta(
balance=False, balance=False,
feature_transforms=None, feature_transforms=None,
) -> dict: ) -> dict:
"""导入语音数据,并返回numpy打包train/test dataset相关属性的ndarray类型 """
如果只想提取train/test dataset中的一方,那么另一方就传None(或者不传对应参数) 根据meta文件,提取/导入语音数据(numpy特征),并返回numpy打包train/test dataset相关属性的ndarray类型
如果只想提取train/test dataset中的一方,那么另一方就传None(或者不传对应参数)即,前两个参数中允许其中一个为None
Parameters Parameters
---------- ----------
train_desc_files : list train_desc_files : list
train_meta_files 需要提取特征的语音文件列表信息,作为训练集
test_desc_files : list test_desc_files : list
test_meta_files 需要提取特征的语音文件列表信息,作为测试集
f_config : dict, optional f_config : list[str], optional
需要提取的特征, by default None 需要提取的特征组合, by default None
e_config : list, optional e_config : list[str], optional
需要使用的情感类别字符串构成的列表, by default ['sad', 'neutral', 'happy'] 需要使用的情感组合,类别字符串构成的列表, by default ['sad', 'neutral', 'happy']
classification_task : bool, optional classification_task : bool, optional
是否采用分类(否则使用回归模型), by default True 是否采用分类模型(否则使用回归模型), by default True
shuffle : bool, optional shuffle : bool, optional
是否打乱顺序, by default True 是否打乱顺序, by default True
balance : bool, optional balance : bool, optional
...@@ -948,15 +967,27 @@ def load_data_from_meta( ...@@ -948,15 +967,27 @@ def load_data_from_meta(
} }
if __name__ == "__main__":
ftd = dict(std_scaler=False, pca_params=dict(n_components=39)) def load_data_from_meta_demo():
ae = AudioExtractor( meta_dict=dict(
e_config=e_config_def, train_meta_files=meta_dir/'train_emodb_HNS.csv',
f_config=f_config_def, shuffle=True, feature_transforms_dict=ftd test_meta_files=meta_dir/'test_emodb_HNS.csv',
) )
print(ae) res=load_data_from_meta(**meta_dict,f_config=f_config_def)
ae._extract_feature_in_meta(meta_path=train_emodb_csv)
return res
if __name__ == "__main__":
load_data_from_meta_demo()
# ftd = dict(std_scaler=False, pca_params=dict(n_components=3))
# ae = AudioExtractor(
# e_config=e_config_def,
# f_config=f_config_def, shuffle=True, feature_transforms_dict=ftd
# )
# print(ae)
# ae._extract_feature_in_meta(meta_path=train_emodb_csv)
# data = load_data_from_meta( # data = load_data_from_meta(
# # train_meta_files=train_emodb_csv, # # train_meta_files=train_emodb_csv,
# test_meta_files=test_emodb_csv, # test_meta_files=test_emodb_csv,
...@@ -964,3 +995,4 @@ if __name__ == "__main__": ...@@ -964,3 +995,4 @@ if __name__ == "__main__":
# # balance=False, # # balance=False,
# balance=True, # balance=True,
# ) # )
...@@ -59,24 +59,32 @@ def showMelFreqGraph(audio_path=audio_file): ...@@ -59,24 +59,32 @@ def showMelFreqGraph(audio_path=audio_file):
y, sr = librosa.load(audio_path) y, sr = librosa.load(audio_path)
# 计算Mel频谱 # 计算Mel频谱
S = librosa.feature.melspectrogram(y, sr=sr, n_mels=128) S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128)
#另一种等效写法:(使用S参数)
# D=np.abs(librosa.stft(y))**2
# S=librosa.feature.melspectrogram(S=D, sr=sr, n_mels=128)
# 将Mel频谱转换为分贝表示 # 将Mel频谱转换为分贝表示
S_db = librosa.power_to_db(S, ref=np.max) S_db = librosa.power_to_db(S, ref=np.max)
# 绘制Mel频谱图 # 绘制Mel频谱(系数)图
fig,ax=plt.subplots()
# plt.figure(figsize=(10, 4)) # plt.figure(figsize=(10, 4))
librosa.display.specshow(S_db, x_axis='time', y_axis='mel', sr=sr, fmax=8000) img=librosa.display.specshow(S_db, x_axis='time', y_axis='mel', sr=sr, fmax=8000,ax=ax)
plt.colorbar(format='%+2.0f dB')
fig.colorbar(img,ax=ax,format='%+2.0f dB')
ax.set(title='Mel-frequencey spectrogram')
# plt.title('Mel频谱图') # plt.title('Mel频谱图')
# plt.xlabel('时间') # plt.xlabel('时间')
# plt.ylabel('频率(Mel刻度)') # plt.ylabel('频率(Mel刻度)')
# plt.show() plt.show()
def showMFCCGraph(audio_path=audio_file):
pass
if __name__=="__main__": if __name__=="__main__":
pass
# showWaveForm() # showWaveForm()
showFreqGraph() # showFreqGraph()
# showMelFreqForm() showMelFreqGraph()
##
\ No newline at end of file \ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
- 启动系统
- 选择语料库组合
- 配置情感组合
- 配置情感特征
- 配置配置预处理参数
-
\ No newline at end of file
此差异已折叠。
此差异已折叠。
本文是本人本科阶段第一次完成一篇完整的论文写作.在本文完成的过程中,除了个人努力以外还得到了许多人的支持和帮助。
首先,我要感谢指导老师蒋海华老师,他在整个毕设的过程中给予了我宝贵的指导和建议,使我能够更好地理解和掌握语音情感识别的相关知识和技术。蒋老师的专业知识、严谨态度和无私奉献精神,对我的毕设研究起到了至关重要的作用。
其次,我要感谢陪伴我共同学习的同学们和教授过我专业课的老师们,在写作本文期间,他们直接或间接的向我提供了帮助。感谢学校为我提供了良好的学习和研究的环境与氛围,使我能够完成此次毕业设计和论文写作。
在此,我还要感谢为本研究提供了宝贵语音数据的人员以及开发工具框架的工程师,他们为本研究做出了重要贡献。最后,我要感谢我的家人和朋友们,在我完成毕设的过程中给予了我无尽的关心和支持,他们的关爱和鼓励,是我不断前行和超越自我的动力源泉。
此差异已折叠。
,path,emotion ,path,emotion
0,D:\repos\CCSER\SER\data\emodb\wav\12b02Fb.wav,happy 27,D:\repos\CCSER\SER\data\emodb\wav\14b02Fb.wav,happy
19,D:\repos\CCSER\SER\data\emodb\wav\08a05Fe.wav,happy 2,D:\repos\CCSER\SER\data\emodb\wav\08b01Fd.wav,happy
27,D:\repos\CCSER\SER\data\emodb\wav\16a07Fb.wav,happy 26,D:\repos\CCSER\SER\data\emodb\wav\11b09Fd.wav,happy
29,D:\repos\CCSER\SER\data\emodb\wav\11a05Fb.wav,happy 25,D:\repos\CCSER\SER\data\emodb\wav\08b09Fd.wav,happy
12,D:\repos\CCSER\SER\data\emodb\wav\10b10Fc.wav,happy 38,D:\repos\CCSER\SER\data\emodb\wav\10b10Fc.wav,happy
20,D:\repos\CCSER\SER\data\emodb\wav\10b01Fa.wav,happy 23,D:\repos\CCSER\SER\data\emodb\wav\09b03Fa.wav,happy
8,D:\repos\CCSER\SER\data\emodb\wav\14b02Fb.wav,happy 8,D:\repos\CCSER\SER\data\emodb\wav\15a05Fb.wav,happy
41,D:\repos\CCSER\SER\data\emodb\wav\11b09Fd.wav,happy 36,D:\repos\CCSER\SER\data\emodb\wav\13a04Fc.wav,happy
36,D:\repos\CCSER\SER\data\emodb\wav\14b01Fc.wav,happy 30,D:\repos\CCSER\SER\data\emodb\wav\11a04Fd.wav,happy
39,D:\repos\CCSER\SER\data\emodb\wav\09b03Fd.wav,happy 42,D:\repos\CCSER\SER\data\emodb\wav\08b01Na.wav,neutral
40,D:\repos\CCSER\SER\data\emodb\wav\16b03Fd.wav,happy 24,D:\repos\CCSER\SER\data\emodb\wav\03b01Nb.wav,neutral
1,D:\repos\CCSER\SER\data\emodb\wav\08b09Fd.wav,happy 41,D:\repos\CCSER\SER\data\emodb\wav\09b02Na.wav,neutral
7,D:\repos\CCSER\SER\data\emodb\wav\09a01Fa.wav,happy 32,D:\repos\CCSER\SER\data\emodb\wav\09b09Nd.wav,neutral
35,D:\repos\CCSER\SER\data\emodb\wav\14b02Na.wav,neutral 19,D:\repos\CCSER\SER\data\emodb\wav\10b02Na.wav,neutral
37,D:\repos\CCSER\SER\data\emodb\wav\14a02Nc.wav,neutral 33,D:\repos\CCSER\SER\data\emodb\wav\16a07Nb.wav,neutral
32,D:\repos\CCSER\SER\data\emodb\wav\03b10Nc.wav,neutral 34,D:\repos\CCSER\SER\data\emodb\wav\03b09Nc.wav,neutral
38,D:\repos\CCSER\SER\data\emodb\wav\15b10Nb.wav,neutral 14,D:\repos\CCSER\SER\data\emodb\wav\08b10Nc.wav,neutral
31,D:\repos\CCSER\SER\data\emodb\wav\15b10Nc.wav,neutral 15,D:\repos\CCSER\SER\data\emodb\wav\13b02Nb.wav,neutral
30,D:\repos\CCSER\SER\data\emodb\wav\11b10Nc.wav,neutral 35,D:\repos\CCSER\SER\data\emodb\wav\09b01Na.wav,neutral
26,D:\repos\CCSER\SER\data\emodb\wav\14a05Na.wav,neutral 12,D:\repos\CCSER\SER\data\emodb\wav\11a04Nd.wav,neutral
25,D:\repos\CCSER\SER\data\emodb\wav\10a01Nb.wav,neutral 10,D:\repos\CCSER\SER\data\emodb\wav\13b01Nc.wav,neutral
33,D:\repos\CCSER\SER\data\emodb\wav\13a07Na.wav,neutral 37,D:\repos\CCSER\SER\data\emodb\wav\13a05Nb.wav,neutral
21,D:\repos\CCSER\SER\data\emodb\wav\03a02Nc.wav,neutral 7,D:\repos\CCSER\SER\data\emodb\wav\09a07Na.wav,neutral
42,D:\repos\CCSER\SER\data\emodb\wav\09a04Nb.wav,neutral 6,D:\repos\CCSER\SER\data\emodb\wav\09a04Nb.wav,neutral
2,D:\repos\CCSER\SER\data\emodb\wav\13b09Na.wav,neutral 39,D:\repos\CCSER\SER\data\emodb\wav\15b09Nb.wav,neutral
18,D:\repos\CCSER\SER\data\emodb\wav\13b01Nc.wav,neutral 40,D:\repos\CCSER\SER\data\emodb\wav\15b10Nb.wav,neutral
17,D:\repos\CCSER\SER\data\emodb\wav\03b03Nb.wav,neutral 1,D:\repos\CCSER\SER\data\emodb\wav\16b03Nb.wav,neutral
16,D:\repos\CCSER\SER\data\emodb\wav\09b10Nd.wav,neutral 16,D:\repos\CCSER\SER\data\emodb\wav\08a02Na.wav,neutral
3,D:\repos\CCSER\SER\data\emodb\wav\13b02Nb.wav,neutral 29,D:\repos\CCSER\SER\data\emodb\wav\13a01Nb.wav,neutral
4,D:\repos\CCSER\SER\data\emodb\wav\10a04Nb.wav,neutral 31,D:\repos\CCSER\SER\data\emodb\wav\11b10Td.wav,sad
22,D:\repos\CCSER\SER\data\emodb\wav\09a07Na.wav,neutral 0,D:\repos\CCSER\SER\data\emodb\wav\12b01Ta.wav,sad
10,D:\repos\CCSER\SER\data\emodb\wav\14a07Na.wav,neutral 22,D:\repos\CCSER\SER\data\emodb\wav\13a02Ta.wav,sad
9,D:\repos\CCSER\SER\data\emodb\wav\15a05Na.wav,neutral 20,D:\repos\CCSER\SER\data\emodb\wav\10b03Tb.wav,sad
18,D:\repos\CCSER\SER\data\emodb\wav\13a05Tc.wav,sad
17,D:\repos\CCSER\SER\data\emodb\wav\09a05Tb.wav,sad
13,D:\repos\CCSER\SER\data\emodb\wav\16a02Tc.wav,sad
11,D:\repos\CCSER\SER\data\emodb\wav\08b02Tc.wav,sad
9,D:\repos\CCSER\SER\data\emodb\wav\12b03Ta.wav,sad
5,D:\repos\CCSER\SER\data\emodb\wav\10a05Tb.wav,sad 5,D:\repos\CCSER\SER\data\emodb\wav\10a05Tb.wav,sad
6,D:\repos\CCSER\SER\data\emodb\wav\16a07Td.wav,sad 4,D:\repos\CCSER\SER\data\emodb\wav\08a07Ta.wav,sad
23,D:\repos\CCSER\SER\data\emodb\wav\14b03Ta.wav,sad 3,D:\repos\CCSER\SER\data\emodb\wav\14a07Tc.wav,sad
13,D:\repos\CCSER\SER\data\emodb\wav\11a07Ta.wav,sad
14,D:\repos\CCSER\SER\data\emodb\wav\15b09Ta.wav,sad
15,D:\repos\CCSER\SER\data\emodb\wav\16b01Tb.wav,sad
28,D:\repos\CCSER\SER\data\emodb\wav\08b03Tc.wav,sad 28,D:\repos\CCSER\SER\data\emodb\wav\08b03Tc.wav,sad
24,D:\repos\CCSER\SER\data\emodb\wav\14a04Tb.wav,sad 21,D:\repos\CCSER\SER\data\emodb\wav\08a07Tb.wav,sad
34,D:\repos\CCSER\SER\data\emodb\wav\14b02Tc.wav,sad
11,D:\repos\CCSER\SER\data\emodb\wav\16b10Td.wav,sad
,path,emotion ,path,emotion
0,D:\repos\CCSER\SER\data\emodb\wav\03a01Fa.wav,happy 92,D:\repos\CCSER\SER\data\emodb\wav\03a01Fa.wav,happy
98,D:\repos\CCSER\SER\data\emodb\wav\14a05Fa.wav,happy 136,D:\repos\CCSER\SER\data\emodb\wav\14b09Fc.wav,happy
97,D:\repos\CCSER\SER\data\emodb\wav\11a02Fb.wav,happy 35,D:\repos\CCSER\SER\data\emodb\wav\13a07Fd.wav,happy
96,D:\repos\CCSER\SER\data\emodb\wav\03b01Fa.wav,happy 74,D:\repos\CCSER\SER\data\emodb\wav\09b03Fd.wav,happy
94,D:\repos\CCSER\SER\data\emodb\wav\14a07Fd.wav,happy 37,D:\repos\CCSER\SER\data\emodb\wav\14a05Fa.wav,happy
93,D:\repos\CCSER\SER\data\emodb\wav\09a04Fd.wav,happy 38,D:\repos\CCSER\SER\data\emodb\wav\08b10Fd.wav,happy
91,D:\repos\CCSER\SER\data\emodb\wav\11b02Fd.wav,happy 125,D:\repos\CCSER\SER\data\emodb\wav\14a02Fd.wav,happy
89,D:\repos\CCSER\SER\data\emodb\wav\15a01Fb.wav,happy 40,D:\repos\CCSER\SER\data\emodb\wav\15a07Fb.wav,happy
88,D:\repos\CCSER\SER\data\emodb\wav\11a05Fc.wav,happy 41,D:\repos\CCSER\SER\data\emodb\wav\13a02Fa.wav,happy
99,D:\repos\CCSER\SER\data\emodb\wav\13b09Fb.wav,happy 167,D:\repos\CCSER\SER\data\emodb\wav\08b01Fe.wav,happy
86,D:\repos\CCSER\SER\data\emodb\wav\08a02Fe.wav,happy 123,D:\repos\CCSER\SER\data\emodb\wav\10a04Fd.wav,happy
77,D:\repos\CCSER\SER\data\emodb\wav\09b03Fa.wav,happy 95,D:\repos\CCSER\SER\data\emodb\wav\11a02Fb.wav,happy
72,D:\repos\CCSER\SER\data\emodb\wav\16b02Fd.wav,happy 121,D:\repos\CCSER\SER\data\emodb\wav\13b02Fb.wav,happy
71,D:\repos\CCSER\SER\data\emodb\wav\08b03Fe.wav,happy 46,D:\repos\CCSER\SER\data\emodb\wav\16a07Fa.wav,happy
69,D:\repos\CCSER\SER\data\emodb\wav\15a07Fb.wav,happy 119,D:\repos\CCSER\SER\data\emodb\wav\11a05Fc.wav,happy
68,D:\repos\CCSER\SER\data\emodb\wav\15a05Fb.wav,happy 48,D:\repos\CCSER\SER\data\emodb\wav\11b01Fc.wav,happy
64,D:\repos\CCSER\SER\data\emodb\wav\12a01Fb.wav,happy 117,D:\repos\CCSER\SER\data\emodb\wav\09a01Fa.wav,happy
61,D:\repos\CCSER\SER\data\emodb\wav\03a07Fb.wav,happy 116,D:\repos\CCSER\SER\data\emodb\wav\08b03Fe.wav,happy
56,D:\repos\CCSER\SER\data\emodb\wav\16a07Fa.wav,happy 51,D:\repos\CCSER\SER\data\emodb\wav\08a04Ff.wav,happy
167,D:\repos\CCSER\SER\data\emodb\wav\13a01Fd.wav,happy 52,D:\repos\CCSER\SER\data\emodb\wav\15a04Fd.wav,happy
53,D:\repos\CCSER\SER\data\emodb\wav\13b01Fc.wav,happy 53,D:\repos\CCSER\SER\data\emodb\wav\16a07Fb.wav,happy
100,D:\repos\CCSER\SER\data\emodb\wav\08b10Fd.wav,happy 55,D:\repos\CCSER\SER\data\emodb\wav\16a04Fa.wav,happy
104,D:\repos\CCSER\SER\data\emodb\wav\13b02Fb.wav,happy 111,D:\repos\CCSER\SER\data\emodb\wav\08a01Fd.wav,happy
157,D:\repos\CCSER\SER\data\emodb\wav\14a02Fd.wav,happy 97,D:\repos\CCSER\SER\data\emodb\wav\08a07Fd.wav,happy
148,D:\repos\CCSER\SER\data\emodb\wav\11a04Fd.wav,happy 108,D:\repos\CCSER\SER\data\emodb\wav\16b02Fd.wav,happy
143,D:\repos\CCSER\SER\data\emodb\wav\14b09Fc.wav,happy 59,D:\repos\CCSER\SER\data\emodb\wav\14b01Fc.wav,happy
142,D:\repos\CCSER\SER\data\emodb\wav\14a05Fb.wav,happy 70,D:\repos\CCSER\SER\data\emodb\wav\13b01Fc.wav,happy
139,D:\repos\CCSER\SER\data\emodb\wav\16b09Fb.wav,happy 98,D:\repos\CCSER\SER\data\emodb\wav\03a04Fd.wav,happy
135,D:\repos\CCSER\SER\data\emodb\wav\13a04Fc.wav,happy 100,D:\repos\CCSER\SER\data\emodb\wav\03a07Fb.wav,happy
133,D:\repos\CCSER\SER\data\emodb\wav\03a04Fd.wav,happy 101,D:\repos\CCSER\SER\data\emodb\wav\13b09Fb.wav,happy
131,D:\repos\CCSER\SER\data\emodb\wav\16b10Fb.wav,happy 137,D:\repos\CCSER\SER\data\emodb\wav\09a04Fd.wav,happy
103,D:\repos\CCSER\SER\data\emodb\wav\08b02Ff.wav,happy 64,D:\repos\CCSER\SER\data\emodb\wav\13b09Fc.wav,happy
129,D:\repos\CCSER\SER\data\emodb\wav\08b01Fd.wav,happy 103,D:\repos\CCSER\SER\data\emodb\wav\16b01Fa.wav,happy
122,D:\repos\CCSER\SER\data\emodb\wav\15a04Fd.wav,happy 156,D:\repos\CCSER\SER\data\emodb\wav\10b01Fa.wav,happy
120,D:\repos\CCSER\SER\data\emodb\wav\16a04Fa.wav,happy 2,D:\repos\CCSER\SER\data\emodb\wav\14a05Fb.wav,happy
119,D:\repos\CCSER\SER\data\emodb\wav\16a05Fc.wav,happy 81,D:\repos\CCSER\SER\data\emodb\wav\16b03Fd.wav,happy
117,D:\repos\CCSER\SER\data\emodb\wav\13b10Fa.wav,happy 7,D:\repos\CCSER\SER\data\emodb\wav\15a01Fb.wav,happy
114,D:\repos\CCSER\SER\data\emodb\wav\16b03Fa.wav,happy 8,D:\repos\CCSER\SER\data\emodb\wav\08a05Fe.wav,happy
112,D:\repos\CCSER\SER\data\emodb\wav\08b01Fe.wav,happy 9,D:\repos\CCSER\SER\data\emodb\wav\12b02Fb.wav,happy
110,D:\repos\CCSER\SER\data\emodb\wav\03a02Fc.wav,happy 1,D:\repos\CCSER\SER\data\emodb\wav\03b01Fa.wav,happy
106,D:\repos\CCSER\SER\data\emodb\wav\08a04Ff.wav,happy 163,D:\repos\CCSER\SER\data\emodb\wav\11a05Fb.wav,happy
127,D:\repos\CCSER\SER\data\emodb\wav\13a02Fa.wav,happy 162,D:\repos\CCSER\SER\data\emodb\wav\15a07Fa.wav,happy
49,D:\repos\CCSER\SER\data\emodb\wav\16b01Fa.wav,happy 80,D:\repos\CCSER\SER\data\emodb\wav\12a01Fb.wav,happy
84,D:\repos\CCSER\SER\data\emodb\wav\13b09Fc.wav,happy 13,D:\repos\CCSER\SER\data\emodb\wav\16b09Fb.wav,happy
168,D:\repos\CCSER\SER\data\emodb\wav\03a05Fc.wav,happy 76,D:\repos\CCSER\SER\data\emodb\wav\08b02Ff.wav,happy
7,D:\repos\CCSER\SER\data\emodb\wav\03a07Fa.wav,happy 155,D:\repos\CCSER\SER\data\emodb\wav\15b09Fa.wav,happy
22,D:\repos\CCSER\SER\data\emodb\wav\08a07Fd.wav,happy 4,D:\repos\CCSER\SER\data\emodb\wav\14b01Fa.wav,happy
21,D:\repos\CCSER\SER\data\emodb\wav\08a01Fd.wav,happy 153,D:\repos\CCSER\SER\data\emodb\wav\03a05Fc.wav,happy
11,D:\repos\CCSER\SER\data\emodb\wav\13a07Fd.wav,happy 150,D:\repos\CCSER\SER\data\emodb\wav\11b03Fc.wav,happy
1,D:\repos\CCSER\SER\data\emodb\wav\11b01Fc.wav,happy 19,D:\repos\CCSER\SER\data\emodb\wav\08a02Fe.wav,happy
13,D:\repos\CCSER\SER\data\emodb\wav\16a01Fc.wav,happy 20,D:\repos\CCSER\SER\data\emodb\wav\14a07Fd.wav,happy
38,D:\repos\CCSER\SER\data\emodb\wav\13b03Fd.wav,happy 149,D:\repos\CCSER\SER\data\emodb\wav\16b10Fb.wav,happy
14,D:\repos\CCSER\SER\data\emodb\wav\15a07Fa.wav,happy 148,D:\repos\CCSER\SER\data\emodb\wav\13b03Fd.wav,happy
43,D:\repos\CCSER\SER\data\emodb\wav\10a02Fa.wav,happy 145,D:\repos\CCSER\SER\data\emodb\wav\03a02Fc.wav,happy
5,D:\repos\CCSER\SER\data\emodb\wav\11b03Fc.wav,happy 24,D:\repos\CCSER\SER\data\emodb\wav\10a02Fa.wav,happy
2,D:\repos\CCSER\SER\data\emodb\wav\14b01Fa.wav,happy 144,D:\repos\CCSER\SER\data\emodb\wav\16b03Fa.wav,happy
8,D:\repos\CCSER\SER\data\emodb\wav\10a04Fd.wav,happy 78,D:\repos\CCSER\SER\data\emodb\wav\16a05Fc.wav,happy
15,D:\repos\CCSER\SER\data\emodb\wav\15b09Fa.wav,happy 27,D:\repos\CCSER\SER\data\emodb\wav\03a07Fa.wav,happy
126,D:\repos\CCSER\SER\data\emodb\wav\15a07Nc.wav,neutral 28,D:\repos\CCSER\SER\data\emodb\wav\13b10Fa.wav,happy
116,D:\repos\CCSER\SER\data\emodb\wav\10b02Na.wav,neutral 142,D:\repos\CCSER\SER\data\emodb\wav\11b02Fd.wav,happy
111,D:\repos\CCSER\SER\data\emodb\wav\09b01Na.wav,neutral 90,D:\repos\CCSER\SER\data\emodb\wav\13a01Fd.wav,happy
113,D:\repos\CCSER\SER\data\emodb\wav\11a04Nd.wav,neutral 88,D:\repos\CCSER\SER\data\emodb\wav\16a01Fc.wav,happy
108,D:\repos\CCSER\SER\data\emodb\wav\14b01Na.wav,neutral 91,D:\repos\CCSER\SER\data\emodb\wav\14b02Na.wav,neutral
105,D:\repos\CCSER\SER\data\emodb\wav\15a04Nc.wav,neutral 96,D:\repos\CCSER\SER\data\emodb\wav\03b10Na.wav,neutral
19,D:\repos\CCSER\SER\data\emodb\wav\13a01Nb.wav,neutral 89,D:\repos\CCSER\SER\data\emodb\wav\15b01Na.wav,neutral
20,D:\repos\CCSER\SER\data\emodb\wav\11a02Nc.wav,neutral 0,D:\repos\CCSER\SER\data\emodb\wav\14b10Nb.wav,neutral
101,D:\repos\CCSER\SER\data\emodb\wav\13a05Nb.wav,neutral 124,D:\repos\CCSER\SER\data\emodb\wav\08a05Nb.wav,neutral
23,D:\repos\CCSER\SER\data\emodb\wav\08b02Nb.wav,neutral 104,D:\repos\CCSER\SER\data\emodb\wav\03b03Nb.wav,neutral
24,D:\repos\CCSER\SER\data\emodb\wav\15b01Na.wav,neutral 166,D:\repos\CCSER\SER\data\emodb\wav\10a04Nb.wav,neutral
115,D:\repos\CCSER\SER\data\emodb\wav\13a02Nc.wav,neutral 165,D:\repos\CCSER\SER\data\emodb\wav\16a02Nb.wav,neutral
128,D:\repos\CCSER\SER\data\emodb\wav\08a02Na.wav,neutral 164,D:\repos\CCSER\SER\data\emodb\wav\15b10Nc.wav,neutral
132,D:\repos\CCSER\SER\data\emodb\wav\09a05Nb.wav,neutral 159,D:\repos\CCSER\SER\data\emodb\wav\12a05Nd.wav,neutral
25,D:\repos\CCSER\SER\data\emodb\wav\08a05Nb.wav,neutral 151,D:\repos\CCSER\SER\data\emodb\wav\15b03Nb.wav,neutral
166,D:\repos\CCSER\SER\data\emodb\wav\03a07Nc.wav,neutral 143,D:\repos\CCSER\SER\data\emodb\wav\09a05Nb.wav,neutral
163,D:\repos\CCSER\SER\data\emodb\wav\16b03Nb.wav,neutral 140,D:\repos\CCSER\SER\data\emodb\wav\03a07Nc.wav,neutral
161,D:\repos\CCSER\SER\data\emodb\wav\15b09Nb.wav,neutral 102,D:\repos\CCSER\SER\data\emodb\wav\15a01Nb.wav,neutral
160,D:\repos\CCSER\SER\data\emodb\wav\13b10Nc.wav,neutral 139,D:\repos\CCSER\SER\data\emodb\wav\13b10Nc.wav,neutral
159,D:\repos\CCSER\SER\data\emodb\wav\08b01Na.wav,neutral 129,D:\repos\CCSER\SER\data\emodb\wav\12a01Nb.wav,neutral
156,D:\repos\CCSER\SER\data\emodb\wav\14b10Nb.wav,neutral 122,D:\repos\CCSER\SER\data\emodb\wav\10a02Na.wav,neutral
153,D:\repos\CCSER\SER\data\emodb\wav\03a04Nc.wav,neutral 113,D:\repos\CCSER\SER\data\emodb\wav\08b09Nb.wav,neutral
152,D:\repos\CCSER\SER\data\emodb\wav\15a01Nb.wav,neutral 109,D:\repos\CCSER\SER\data\emodb\wav\11b03Nb.wav,neutral
9,D:\repos\CCSER\SER\data\emodb\wav\11b03Nb.wav,neutral 107,D:\repos\CCSER\SER\data\emodb\wav\08a04Nc.wav,neutral
151,D:\repos\CCSER\SER\data\emodb\wav\03a05Nd.wav,neutral 106,D:\repos\CCSER\SER\data\emodb\wav\09a01Nb.wav,neutral
147,D:\repos\CCSER\SER\data\emodb\wav\08a01Na.wav,neutral 105,D:\repos\CCSER\SER\data\emodb\wav\03a04Nc.wav,neutral
144,D:\repos\CCSER\SER\data\emodb\wav\11b02Na.wav,neutral 138,D:\repos\CCSER\SER\data\emodb\wav\11a01Nd.wav,neutral
3,D:\repos\CCSER\SER\data\emodb\wav\09b02Na.wav,neutral 87,D:\repos\CCSER\SER\data\emodb\wav\12b02Na.wav,neutral
141,D:\repos\CCSER\SER\data\emodb\wav\09b09Nd.wav,neutral 84,D:\repos\CCSER\SER\data\emodb\wav\09b10Nd.wav,neutral
140,D:\repos\CCSER\SER\data\emodb\wav\03b10Na.wav,neutral 168,D:\repos\CCSER\SER\data\emodb\wav\11b02Na.wav,neutral
137,D:\repos\CCSER\SER\data\emodb\wav\15a02Na.wav,neutral 57,D:\repos\CCSER\SER\data\emodb\wav\11a02Nc.wav,neutral
136,D:\repos\CCSER\SER\data\emodb\wav\03b01Nb.wav,neutral 56,D:\repos\CCSER\SER\data\emodb\wav\08b02Nb.wav,neutral
6,D:\repos\CCSER\SER\data\emodb\wav\16a01Nc.wav,neutral 33,D:\repos\CCSER\SER\data\emodb\wav\03a05Nd.wav,neutral
149,D:\repos\CCSER\SER\data\emodb\wav\12b02Na.wav,neutral 16,D:\repos\CCSER\SER\data\emodb\wav\10a01Nb.wav,neutral
26,D:\repos\CCSER\SER\data\emodb\wav\15b02Nd.wav,neutral 49,D:\repos\CCSER\SER\data\emodb\wav\14a07Na.wav,neutral
18,D:\repos\CCSER\SER\data\emodb\wav\08a07Na.wav,neutral 17,D:\repos\CCSER\SER\data\emodb\wav\13b03Na.wav,neutral
92,D:\repos\CCSER\SER\data\emodb\wav\08b09Nb.wav,neutral 45,D:\repos\CCSER\SER\data\emodb\wav\15a02Na.wav,neutral
33,D:\repos\CCSER\SER\data\emodb\wav\09a01Nb.wav,neutral 58,D:\repos\CCSER\SER\data\emodb\wav\08a07Na.wav,neutral
75,D:\repos\CCSER\SER\data\emodb\wav\11b01Nc.wav,neutral 44,D:\repos\CCSER\SER\data\emodb\wav\03b10Nc.wav,neutral
73,D:\repos\CCSER\SER\data\emodb\wav\08a04Nc.wav,neutral 42,D:\repos\CCSER\SER\data\emodb\wav\13a02Nc.wav,neutral
34,D:\repos\CCSER\SER\data\emodb\wav\12a01Nb.wav,neutral 86,D:\repos\CCSER\SER\data\emodb\wav\13a07Na.wav,neutral
35,D:\repos\CCSER\SER\data\emodb\wav\16a02Nb.wav,neutral 36,D:\repos\CCSER\SER\data\emodb\wav\14a05Na.wav,neutral
70,D:\repos\CCSER\SER\data\emodb\wav\14a01Na.wav,neutral 23,D:\repos\CCSER\SER\data\emodb\wav\16a01Nc.wav,neutral
37,D:\repos\CCSER\SER\data\emodb\wav\11a05Na.wav,neutral 26,D:\repos\CCSER\SER\data\emodb\wav\03a01Nc.wav,neutral
59,D:\repos\CCSER\SER\data\emodb\wav\11b09Na.wav,neutral 30,D:\repos\CCSER\SER\data\emodb\wav\15b02Nd.wav,neutral
57,D:\repos\CCSER\SER\data\emodb\wav\10a02Na.wav,neutral 34,D:\repos\CCSER\SER\data\emodb\wav\14b01Na.wav,neutral
54,D:\repos\CCSER\SER\data\emodb\wav\16a04Nc.wav,neutral 43,D:\repos\CCSER\SER\data\emodb\wav\09b03Nb.wav,neutral
50,D:\repos\CCSER\SER\data\emodb\wav\12a02Nb.wav,neutral 60,D:\repos\CCSER\SER\data\emodb\wav\11b10Nc.wav,neutral
42,D:\repos\CCSER\SER\data\emodb\wav\16a07Nb.wav,neutral 32,D:\repos\CCSER\SER\data\emodb\wav\11a05Na.wav,neutral
48,D:\repos\CCSER\SER\data\emodb\wav\03b09Nc.wav,neutral 12,D:\repos\CCSER\SER\data\emodb\wav\14a02Nc.wav,neutral
46,D:\repos\CCSER\SER\data\emodb\wav\09b03Nb.wav,neutral 3,D:\repos\CCSER\SER\data\emodb\wav\03b02Na.wav,neutral
45,D:\repos\CCSER\SER\data\emodb\wav\03a01Nc.wav,neutral 82,D:\repos\CCSER\SER\data\emodb\wav\03a02Nc.wav,neutral
78,D:\repos\CCSER\SER\data\emodb\wav\08b03Nb.wav,neutral 79,D:\repos\CCSER\SER\data\emodb\wav\08a01Na.wav,neutral
79,D:\repos\CCSER\SER\data\emodb\wav\08b10Nc.wav,neutral 77,D:\repos\CCSER\SER\data\emodb\wav\16a04Nc.wav,neutral
36,D:\repos\CCSER\SER\data\emodb\wav\13b03Na.wav,neutral 75,D:\repos\CCSER\SER\data\emodb\wav\14a01Na.wav,neutral
80,D:\repos\CCSER\SER\data\emodb\wav\15b03Nb.wav,neutral 73,D:\repos\CCSER\SER\data\emodb\wav\15a04Nc.wav,neutral
85,D:\repos\CCSER\SER\data\emodb\wav\11a01Nd.wav,neutral 71,D:\repos\CCSER\SER\data\emodb\wav\13b09Na.wav,neutral
90,D:\repos\CCSER\SER\data\emodb\wav\03b02Na.wav,neutral 69,D:\repos\CCSER\SER\data\emodb\wav\11b01Nc.wav,neutral
82,D:\repos\CCSER\SER\data\emodb\wav\12a05Nd.wav,neutral 10,D:\repos\CCSER\SER\data\emodb\wav\08b03Nb.wav,neutral
28,D:\repos\CCSER\SER\data\emodb\wav\08b10Tc.wav,sad 72,D:\repos\CCSER\SER\data\emodb\wav\11b09Na.wav,neutral
58,D:\repos\CCSER\SER\data\emodb\wav\13a07Tc.wav,sad 68,D:\repos\CCSER\SER\data\emodb\wav\12a02Nb.wav,neutral
145,D:\repos\CCSER\SER\data\emodb\wav\08a04Tb.wav,sad 11,D:\repos\CCSER\SER\data\emodb\wav\15a05Na.wav,neutral
146,D:\repos\CCSER\SER\data\emodb\wav\13a02Ta.wav,sad 67,D:\repos\CCSER\SER\data\emodb\wav\15a07Nc.wav,neutral
31,D:\repos\CCSER\SER\data\emodb\wav\14a04Tc.wav,sad 160,D:\repos\CCSER\SER\data\emodb\wav\11a07Ta.wav,sad
40,D:\repos\CCSER\SER\data\emodb\wav\11b02Td.wav,sad 161,D:\repos\CCSER\SER\data\emodb\wav\09a07Ta.wav,sad
55,D:\repos\CCSER\SER\data\emodb\wav\11b03Td.wav,sad 141,D:\repos\CCSER\SER\data\emodb\wav\16b01Tb.wav,sad
95,D:\repos\CCSER\SER\data\emodb\wav\16b10Tb.wav,sad 29,D:\repos\CCSER\SER\data\emodb\wav\08a04Tb.wav,sad
150,D:\repos\CCSER\SER\data\emodb\wav\08a07Tb.wav,sad 157,D:\repos\CCSER\SER\data\emodb\wav\11b03Td.wav,sad
87,D:\repos\CCSER\SER\data\emodb\wav\08a07Ta.wav,sad 25,D:\repos\CCSER\SER\data\emodb\wav\16b03Ta.wav,sad
41,D:\repos\CCSER\SER\data\emodb\wav\16a04Tc.wav,sad 152,D:\repos\CCSER\SER\data\emodb\wav\14a04Tc.wav,sad
52,D:\repos\CCSER\SER\data\emodb\wav\11a05Td.wav,sad 146,D:\repos\CCSER\SER\data\emodb\wav\14a05Tc.wav,sad
154,D:\repos\CCSER\SER\data\emodb\wav\09a05Tb.wav,sad 147,D:\repos\CCSER\SER\data\emodb\wav\03a05Tc.wav,sad
102,D:\repos\CCSER\SER\data\emodb\wav\14b10Tc.wav,sad 22,D:\repos\CCSER\SER\data\emodb\wav\03b01Td.wav,sad
155,D:\repos\CCSER\SER\data\emodb\wav\03a05Tc.wav,sad 6,D:\repos\CCSER\SER\data\emodb\wav\14a05Ta.wav,sad
51,D:\repos\CCSER\SER\data\emodb\wav\16a02Tc.wav,sad 15,D:\repos\CCSER\SER\data\emodb\wav\15b02Tc.wav,sad
30,D:\repos\CCSER\SER\data\emodb\wav\08b02Tc.wav,sad 158,D:\repos\CCSER\SER\data\emodb\wav\16a01Tb.wav,sad
158,D:\repos\CCSER\SER\data\emodb\wav\15b03Tc.wav,sad 154,D:\repos\CCSER\SER\data\emodb\wav\09b02Tb.wav,sad
29,D:\repos\CCSER\SER\data\emodb\wav\08a02Tb.wav,sad 21,D:\repos\CCSER\SER\data\emodb\wav\15a02Ta.wav,sad
165,D:\repos\CCSER\SER\data\emodb\wav\14a07Tc.wav,sad 18,D:\repos\CCSER\SER\data\emodb\wav\11b02Td.wav,sad
47,D:\repos\CCSER\SER\data\emodb\wav\13a05Tc.wav,sad 5,D:\repos\CCSER\SER\data\emodb\wav\08a02Tb.wav,sad
162,D:\repos\CCSER\SER\data\emodb\wav\13b03Td.wav,sad 14,D:\repos\CCSER\SER\data\emodb\wav\14b09Td.wav,sad
164,D:\repos\CCSER\SER\data\emodb\wav\16a05Tb.wav,sad 85,D:\repos\CCSER\SER\data\emodb\wav\16a04Tc.wav,sad
4,D:\repos\CCSER\SER\data\emodb\wav\03a02Ta.wav,sad 135,D:\repos\CCSER\SER\data\emodb\wav\08b09Tb.wav,sad
39,D:\repos\CCSER\SER\data\emodb\wav\16b03Ta.wav,sad 83,D:\repos\CCSER\SER\data\emodb\wav\08b10Tc.wav,sad
16,D:\repos\CCSER\SER\data\emodb\wav\10b03Tb.wav,sad 93,D:\repos\CCSER\SER\data\emodb\wav\14b03Ta.wav,sad
17,D:\repos\CCSER\SER\data\emodb\wav\08b09Tb.wav,sad 94,D:\repos\CCSER\SER\data\emodb\wav\14a04Tb.wav,sad
109,D:\repos\CCSER\SER\data\emodb\wav\14a05Ta.wav,sad 99,D:\repos\CCSER\SER\data\emodb\wav\09b03Ta.wav,sad
76,D:\repos\CCSER\SER\data\emodb\wav\09a07Ta.wav,sad 66,D:\repos\CCSER\SER\data\emodb\wav\03a04Ta.wav,sad
81,D:\repos\CCSER\SER\data\emodb\wav\13a04Ta.wav,sad 65,D:\repos\CCSER\SER\data\emodb\wav\16a07Td.wav,sad
118,D:\repos\CCSER\SER\data\emodb\wav\03b01Td.wav,sad 63,D:\repos\CCSER\SER\data\emodb\wav\08a05Ta.wav,sad
74,D:\repos\CCSER\SER\data\emodb\wav\14a02Tb.wav,sad 62,D:\repos\CCSER\SER\data\emodb\wav\15b09Ta.wav,sad
12,D:\repos\CCSER\SER\data\emodb\wav\11b10Td.wav,sad 61,D:\repos\CCSER\SER\data\emodb\wav\03b09Tc.wav,sad
121,D:\repos\CCSER\SER\data\emodb\wav\12b09Td.wav,sad 110,D:\repos\CCSER\SER\data\emodb\wav\12b09Td.wav,sad
107,D:\repos\CCSER\SER\data\emodb\wav\16a01Tb.wav,sad 112,D:\repos\CCSER\SER\data\emodb\wav\14b02Tc.wav,sad
123,D:\repos\CCSER\SER\data\emodb\wav\11b09Td.wav,sad 54,D:\repos\CCSER\SER\data\emodb\wav\11a02Tc.wav,sad
124,D:\repos\CCSER\SER\data\emodb\wav\12a05Ta.wav,sad 31,D:\repos\CCSER\SER\data\emodb\wav\03b02Tb.wav,sad
60,D:\repos\CCSER\SER\data\emodb\wav\03a04Ta.wav,sad 114,D:\repos\CCSER\SER\data\emodb\wav\13a04Ta.wav,sad
125,D:\repos\CCSER\SER\data\emodb\wav\15b02Tc.wav,sad 50,D:\repos\CCSER\SER\data\emodb\wav\14b10Tc.wav,sad
83,D:\repos\CCSER\SER\data\emodb\wav\03b09Tc.wav,sad 118,D:\repos\CCSER\SER\data\emodb\wav\11a05Td.wav,sad
32,D:\repos\CCSER\SER\data\emodb\wav\15a02Ta.wav,sad 47,D:\repos\CCSER\SER\data\emodb\wav\11b09Td.wav,sad
130,D:\repos\CCSER\SER\data\emodb\wav\09b02Tb.wav,sad 120,D:\repos\CCSER\SER\data\emodb\wav\03a02Ta.wav,sad
27,D:\repos\CCSER\SER\data\emodb\wav\09b03Ta.wav,sad 39,D:\repos\CCSER\SER\data\emodb\wav\10a07Ta.wav,sad
67,D:\repos\CCSER\SER\data\emodb\wav\03b03Tc.wav,sad 126,D:\repos\CCSER\SER\data\emodb\wav\16a05Tb.wav,sad
134,D:\repos\CCSER\SER\data\emodb\wav\14a05Tc.wav,sad 128,D:\repos\CCSER\SER\data\emodb\wav\14a02Tb.wav,sad
66,D:\repos\CCSER\SER\data\emodb\wav\11a02Tc.wav,sad 130,D:\repos\CCSER\SER\data\emodb\wav\12a05Ta.wav,sad
65,D:\repos\CCSER\SER\data\emodb\wav\08a05Ta.wav,sad 131,D:\repos\CCSER\SER\data\emodb\wav\16b10Td.wav,sad
63,D:\repos\CCSER\SER\data\emodb\wav\03b02Tb.wav,sad 132,D:\repos\CCSER\SER\data\emodb\wav\13a07Tc.wav,sad
138,D:\repos\CCSER\SER\data\emodb\wav\12b03Ta.wav,sad 133,D:\repos\CCSER\SER\data\emodb\wav\15b03Tc.wav,sad
62,D:\repos\CCSER\SER\data\emodb\wav\10a07Ta.wav,sad 134,D:\repos\CCSER\SER\data\emodb\wav\03b03Tc.wav,sad
10,D:\repos\CCSER\SER\data\emodb\wav\14b09Td.wav,sad 115,D:\repos\CCSER\SER\data\emodb\wav\13b03Td.wav,sad
44,D:\repos\CCSER\SER\data\emodb\wav\12b01Ta.wav,sad 127,D:\repos\CCSER\SER\data\emodb\wav\16b10Tb.wav,sad
...@@ -32,7 +32,7 @@ from sklearn.svm import SVC ...@@ -32,7 +32,7 @@ from sklearn.svm import SVC
from tqdm import tqdm from tqdm import tqdm
from audio.extractor import AudioExtractor, load_data_from_meta from audio.extractor import AudioExtractor, load_data_from_meta
from config.EF import e_config_def, f_config_def, validate_emotions from config.EF import AHNPS, e_config_def, f_config_def, validate_emotions
from config.MetaPath import ( from config.MetaPath import (
emodb, emodb,
meta_paths_of_db, meta_paths_of_db,
...@@ -713,24 +713,24 @@ def main(): ...@@ -713,24 +713,24 @@ def main():
passive_emo_others = passive_emo + ["others"] passive_emo_others = passive_emo + ["others"]
typical_emo = ["happy", "neutral", "sad"] typical_emo = ["happy", "neutral", "sad"]
AHSO = ["angry", "neutral", "sad", "others"] AHSO = ["angry", "neutral", "sad", "others"]
e_config = passive_emo e_config = AHNPS
f_config = ["mfcc"] f_config = ["mfcc"]
# my_model = RandomForestClassifier(max_depth=3, max_features=0.2) # my_model = RandomForestClassifier(max_depth=3, max_features=0.2)
my_model = SVC(C=0.001, gamma=0.001, kernel="poly", probability=True) my_model = SVC(C=0.001, gamma=0.001, kernel="poly", probability=True)
# my_model=KNeighborsClassifier(n_neighbors=3, p=1, weights='distance') # my_model=KNeighborsClassifier(n_neighbors=3, p=1, weights='distance')
# my_model = None my_model = None
# rec = EmotionRecognizer(model=my_model,e_config=AHNPS,f_config=f_config_def,test_dbs=[ravdess],train_dbs=[ravdess], verbose=1) # rec = EmotionRecognizer(model=my_model,e_config=AHNPS,f_config=f_config_def,test_dbs=[ravdess],train_dbs=[ravdess], verbose=1)
# rec = EmotionRecognizer(model=my_model,e_config=AHNPS,f_config=f_config_def,test_dbs=emodb,train_dbs=emodb, verbose=1) # rec = EmotionRecognizer(model=my_model,e_config=AHNPS,f_config=f_config_def,test_dbs=emodb,train_dbs=emodb, verbose=1)
single_db = emodb # single_db = emodb
meta_dict = {"train_dbs": single_db, "test_dbs": single_db} # meta_dict = {"train_dbs": single_db, "test_dbs": single_db}
# meta_dict=dict( meta_dict=dict(
# train_dbs=emodb, train_dbs=emodb,
# test_dbs=ravdess test_dbs=emodb
# ) )
er = EmotionRecognizer( er = EmotionRecognizer(
model=my_model, model=my_model,
...@@ -739,8 +739,8 @@ def main(): ...@@ -739,8 +739,8 @@ def main():
f_config=f_config, f_config=f_config,
verbose=1, verbose=1,
std_scaler=False, # std_scaler=False,
pca_params=dict(n_components=39) # pca_params=dict(n_components=39)
# std_scaler=False, # std_scaler=False,
# pca={"n_components":"mle"} # pca={"n_components":"mle"}
...@@ -755,7 +755,7 @@ def main(): ...@@ -755,7 +755,7 @@ def main():
cv_score = er.model_cv_score() cv_score = er.model_cv_score()
print(f"{cv_score=}") print(f"{cv_score=}")
print(er.confusion_matrix())
return er return er
......
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import tensorflow as tf\n",
"tf.test.is_built_with_cuda()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Num GPUs Available: 1\n"
]
}
],
"source": [
"import tensorflow as tf\n",
"print(\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "tf2.10",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"X.shape, y.shape: (150, 4) (150,)\n",
"X_train.shape, y_train.shape: (90, 4) (90,)\n",
"X_test.shape, y_test.shape: (60, 4) (60,)\n"
]
},
{
"data": {
"text/plain": [
"0.9666666666666667"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn import datasets\n",
"from sklearn import svm\n",
"\n",
"X, y = datasets.load_iris(return_X_y=True)\n",
"X.shape, y.shape\n",
"print('X.shape, y.shape: ', X.shape, y.shape)\n",
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X, y, test_size=0.4, random_state=0)\n",
"\n",
"X_train.shape, y_train.shape\n",
"print('X_train.shape, y_train.shape: ', X_train.shape, y_train.shape)\n",
"\n",
"X_test.shape, y_test.shape\n",
"print('X_test.shape, y_test.shape: ', X_test.shape, y_test.shape)\n",
"\n",
"\n",
"clf = svm.SVC(kernel='linear', C=1).fit(X_train, y_train)\n",
"clf.score(X_test, y_test)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "tf2.10",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
import os import os
# disable keras loggings # disable keras loggings
import sys import sys
from config.EF import e_config_def from config.EF import e_config_def, f_config_def
stderr = sys.stderr stderr = sys.stderr
sys.stderr = open(os.devnull, "w") sys.stderr = open(os.devnull, "w")
import random import random
from config.MetaPath import savee, emodb, ravdess
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from sklearn.metrics import (accuracy_score, confusion_matrix, from sklearn.metrics import accuracy_score, confusion_matrix, mean_absolute_error
mean_absolute_error)
# import tensorflow as tf # import tensorflow as tf
from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard
from tensorflow.keras.layers import (LSTM, Dense, Dropout) from tensorflow.keras.layers import LSTM, Dense, Dropout
from tensorflow.keras.models import Sequential from tensorflow.keras.models import Sequential
from tensorflow.keras.utils import to_categorical from tensorflow.keras.utils import to_categorical
from audio.core import extract_feature_of_audio, get_dropout_str
from config.EF import validate_emotions from config.EF import validate_emotions
from recognizer.basic import EmotionRecognizer
# from ER import EmotionRecognizer # from ER import EmotionRecognizer
from config.MetaPath import get_first_letters from config.MetaPath import get_first_letters
from audio.core import extract_feature_of_audio, get_dropout_str from recognizer.basic import EmotionRecognizer
class DeepEmotionRecognizer(EmotionRecognizer): class DeepEmotionRecognizer(EmotionRecognizer):
...@@ -128,7 +130,6 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -128,7 +130,6 @@ class DeepEmotionRecognizer(EmotionRecognizer):
) )
# number of classes ( emotions ) # number of classes ( emotions )
self.output_dim = len(self.e_config) self.output_dim = len(self.e_config)
# optimization attributes # optimization attributes
self.optimizer = optimizer if optimizer else "adam" self.optimizer = optimizer if optimizer else "adam"
...@@ -276,7 +277,7 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -276,7 +277,7 @@ class DeepEmotionRecognizer(EmotionRecognizer):
) )
# reshape labels # reshape labels
if(self.y_train is None or self.y_test is None): if self.y_train is None or self.y_test is None:
raise ValueError("y_train and y_test must be array_like ") raise ValueError("y_train and y_test must be array_like ")
y_train_shape = self.y_train.shape y_train_shape = self.y_train.shape
y_test_shape = self.y_test.shape y_test_shape = self.y_test.shape
...@@ -349,9 +350,9 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -349,9 +350,9 @@ class DeepEmotionRecognizer(EmotionRecognizer):
def predict_proba(self, audio_path): def predict_proba(self, audio_path):
if self.classification_task: if self.classification_task:
feature = extract_feature_of_audio(audio_path, **self._f_config_dict).reshape( feature = extract_feature_of_audio(
(1, 1, self.input_length) audio_path, **self._f_config_dict
) ).reshape((1, 1, self.input_length))
proba = self.model.predict(feature)[0][0] proba = self.model.predict(feature)[0][0]
result = {} result = {}
for prob, emotion in zip(proba, self.e_config): for prob, emotion in zip(proba, self.e_config):
...@@ -418,7 +419,7 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -418,7 +419,7 @@ class DeepEmotionRecognizer(EmotionRecognizer):
if partition == "test": if partition == "test":
if self.classification_task: if self.classification_task:
# np.squeeze去除数组中所有维度大小为 1 的维度,从而将数组的维度降低。如果数组没有大小为 1 的维度,则不会有任何变化。 # np.squeeze去除数组中所有维度大小为 1 的维度,从而将数组的维度降低。如果数组没有大小为 1 的维度,则不会有任何变化。
#这里的y_test可能采用oneHotEncoder,因此可以如下计算 # 这里的y_test可能采用oneHotEncoder,因此可以如下计算
y_test = np.array( y_test = np.array(
[ [
np.argmax(y, axis=None, out=None) + 1 np.argmax(y, axis=None, out=None) + 1
...@@ -449,8 +450,12 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -449,8 +450,12 @@ class DeepEmotionRecognizer(EmotionRecognizer):
test_samples = [] test_samples = []
total = [] total = []
for emotion in self.e_config: for emotion in self.e_config:
n_train = self.count_samples_in_partition(self.emotions2int[emotion] + 1, "train") n_train = self.count_samples_in_partition(
n_test = self.count_samples_in_partition(self.emotions2int[emotion] + 1, "test") self.emotions2int[emotion] + 1, "train"
)
n_test = self.count_samples_in_partition(
self.emotions2int[emotion] + 1, "test"
)
train_samples.append(n_train) train_samples.append(n_train)
test_samples.append(n_test) test_samples.append(n_test)
total.append(n_train + n_test) total.append(n_train + n_test)
...@@ -463,7 +468,7 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -463,7 +468,7 @@ class DeepEmotionRecognizer(EmotionRecognizer):
data={"train": train_samples, "test": test_samples, "total": total}, data={"train": train_samples, "test": test_samples, "total": total},
index=self.e_config + ["total"], index=self.e_config + ["total"],
) )
def get_training_and_testing_samples_per_emotion(self): def get_training_and_testing_samples_per_emotion(self):
""" """
Returns a dataframe with the number of training and testing samples Returns a dataframe with the number of training and testing samples
...@@ -473,8 +478,12 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -473,8 +478,12 @@ class DeepEmotionRecognizer(EmotionRecognizer):
test_samples_per_emotion = [] test_samples_per_emotion = []
total_samples_per_emotion = [] total_samples_per_emotion = []
for emotion in self.e_config: for emotion in self.e_config:
n_train = self.count_samples_in_partition(self.emotions2int[emotion] + 1, "train") n_train = self.count_samples_in_partition(
n_test = self.count_samples_in_partition(self.emotions2int[emotion] + 1, "test") self.emotions2int[emotion] + 1, "train"
)
n_test = self.count_samples_in_partition(
self.emotions2int[emotion] + 1, "test"
)
train_samples_per_emotion.append(n_train) train_samples_per_emotion.append(n_train)
test_samples_per_emotion.append(n_test) test_samples_per_emotion.append(n_test)
total_samples_per_emotion.append(n_train + n_test) total_samples_per_emotion.append(n_train + n_test)
...@@ -492,7 +501,6 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -492,7 +501,6 @@ class DeepEmotionRecognizer(EmotionRecognizer):
index=self.e_config + ["Total"], index=self.e_config + ["Total"],
) )
def get_random_emotion_index(self, emotion, partition="train"): def get_random_emotion_index(self, emotion, partition="train"):
""" """
Returns random `emotion` data sample index on `partition` Returns random `emotion` data sample index on `partition`
...@@ -517,21 +525,21 @@ class DeepEmotionRecognizer(EmotionRecognizer): ...@@ -517,21 +525,21 @@ class DeepEmotionRecognizer(EmotionRecognizer):
return index return index
## ##
if __name__ == "__main__": if __name__ == "__main__":
from config.MetaPath import ravdess from config.MetaPath import ravdess
meta_dict = {
"train_dbs":ravdess, meta_dict = {"train_dbs": savee, "test_dbs": emodb}
"test_dbs":ravdess
}
print(meta_dict) print(meta_dict)
der = DeepEmotionRecognizer(**meta_dict, emotions=e_config_def, verbose=0) der = DeepEmotionRecognizer(
**meta_dict, e_config=e_config_def, f_config=f_config_def, epochs=400, verbose=0
)
# #train # #train
der.train() der.train()
print("train_score",der.train_score()) print("train_score", der.train_score())
print("test_score",der.test_score()) print("test_score", der.test_score())
# print(der.train_meta_files,der.test_meta_files) # print(der.train_meta_files,der.test_meta_files)
# der.train(override=False) # der.train(override=False)
# print("Test accuracy score:", der.test_score() * 100, "%") # print("Test accuracy score:", der.test_score() * 100, "%")
此差异已折叠。
...@@ -21,7 +21,16 @@ ...@@ -21,7 +21,16 @@
### versions with time ### versions with time
- **<u>input version under this line:</u>**
- new notes:"Sort update records in descending order of time".That would be convenient to update new version notes in the future.
-
- 2023-05-09@19:10:05
- fix some bugs.
- certain adjustments to the project code.
### old notes
- old notes:"Sort update records in ascending order of time".
- 2023-04-25@21:35:50 - 2023-04-25@21:35:50
- new: - new:
...@@ -41,4 +50,5 @@ ...@@ -41,4 +50,5 @@
- 2023-04-30@00:02:03 - 2023-04-30@00:02:03
- "update PCA transformer to the SER system" - "update PCA transformer to the SER system"
- "there are some problems with recognize the single audio with pca preprocessing,the idea is to save the pca transformer when it was first fited,and then try to load corresponding file(joblib or pickle) when you need to recognize several audios that need extract the required dimension feature" - "there are some problems with recognize the single audio with pca preprocessing,the idea is to save the pca transformer when it was first fited,and then try to load corresponding file(joblib or pickle) when you need to recognize several audios that need extract the required dimension feature"
- -
\ No newline at end of file
d = {'A': [1, 2, 3], 'B': [4, 5, 6], 'C':{"a":[7, 8, 9],"b":7}} import tkinter
import json
from matplotlib.backends.backend_tkagg import (
def dict_to_filetag(d): FigureCanvasTkAgg, NavigationToolbar2Tk)
# Convert dictionary to JSON string # Implement the default Matplotlib key bindings.
json_str = json.dumps(d) from matplotlib.backend_bases import key_press_handler
remove_chars=['"',' '] from matplotlib.figure import Figure
for c in remove_chars:
json_str=json_str.replace(c,'') import numpy as np
# Replace invalid characters with hyphen
rep_dict={
":":"=", root = tkinter.Tk()
# '"':'', root.wm_title("Embedding in Tk")
# "'":""
} def get_fig():
for char in json_str: """
if rep_dict.get(char): Returns a matplotlib Figure object, a numpy array of time values, and a matplotlib Line2D object
json_str = json_str.replace(char, rep_dict[char]) representing the plot of 2*sin(2*pi*t) over the range [0,3]
# Truncate string if too long with a label of "f(t)" on the y-axis and "time [s]"
# max_len = 260 on the x-axis.
# if len(json_str) > max_len: The Figure has a size of 5x4 inches and a DPI of 100. No parameters are required.
# json_str = json_str[:max_len] """
fig = Figure(figsize=(5, 4), dpi=100)
return json_str ax = fig.add_subplot()
ax.set_xlabel("time [s]")
ax.set_ylabel("f(t)")
res=dict_to_filetag(d)
print(res) t = np.arange(0, 3, .01)
line, = ax.plot(t, 2 * np.sin(2 * np.pi * t))
return fig,t,line
fig, t, line = get_fig()
canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
canvas.draw()
# pack_toolbar=False will make it easier to use a layout manager later on.
toolbar = NavigationToolbar2Tk(canvas, root, pack_toolbar=False)
toolbar.update()
canvas.mpl_connect(
"key_press_event", lambda event: print(f"you pressed {event.key}"))
canvas.mpl_connect("key_press_event", key_press_handler)
button_quit = tkinter.Button(master=root, text="Quit", command=root.destroy)
def update_frequency(new_val):
"""
Update plot with new frequency value.
:param new_val: A float representing the new frequency value.
"""
# retrieve frequency
f = float(new_val)
# update data
y = 2 * np.sin(2 * np.pi * f * t)
line.set_data(t, y)
# required to update canvas and attached toolbar!
canvas.draw()
slider_update = tkinter.Scale(root, from_=1, to=5, orient=tkinter.HORIZONTAL,
command=update_frequency, label="Frequency [Hz]")
# Packing order is important. Widgets are processed sequentially and if there
# is no space left, because the window is too small, they are not displayed.
# The canvas is rather flexible in its size, so we pack it last which makes
# sure the UI controls are displayed as long as possible.
button_quit.pack(side=tkinter.BOTTOM)
slider_update.pack(side=tkinter.BOTTOM)
toolbar.pack(side=tkinter.BOTTOM, fill=tkinter.X)
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True)
tkinter.mainloop()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册