Giter Site home page Giter Site logo

qnxgy921 / speech-emotion-recognition-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from renovamen/speech-emotion-recognition

0.0 0.0 0.0 129.78 MB

Speech emotion recognition implemented in Keras (LSTM, CNN, SVM, MLP) | 语音情感识别

License: MIT License

Python 100.00%

speech-emotion-recognition-1's Introduction

Speech Emotion Recognition

用 LSTM、CNN、SVM、MLP 进行语音情感识别,Keras 实现。

改进了特征提取方式,识别准确率提高到了 80% 左右。原来的版本的存档在 First-Version 分支

English Document | 中文文档

 

Environment

Python 3.6.7

Keras 2.2.4

 

Structure

├── models/                // 模型实现
│   ├── common.py          // 所有模型的通用部分(即所有模型都会继承这个类)
│   ├── dnn                // 神经网络模型
│   │   ├── dnn.py         // 神经网络的通用部分
│   │   ├── cnn.py         // CNN
│   │   └── lstm.py        // LSTM
│   └── ml.py              // SVM & MLP
├── extract_feats/         // 特征提取
│   ├── librosa.py         // librosa 提取特征
│   └── opensmile.py       // Opensmile 提取特征
├── utils/
│   ├── files.py           // 用于整理数据集(分类、批量重命名)
│   ├── opts.py            // 使用 argparse 从命令行读入参数
│   └── common.py          // 加载模型、绘图(雷达图、频谱图、波形图)
├── features/              // 存储提取好的特征
├── config/                // 配置参数(.yaml)
├── train.py               // 训练模型
├── predict.py             // 用训练好的模型预测指定音频的情感
└── preprocess.py          // 数据预处理(提取数据集中音频的特征并保存)

 

Requirments

Python

Tools

 

Datasets

  1. RAVDESS

    英文,24 个人(12 名男性,12 名女性)的大约 1500 个音频,表达了 8 种不同的情绪(第三位数字表示情绪类别):01 = neutral,02 = calm,03 = happy,04 = sad,05 = angry,06 = fearful,07 = disgust,08 = surprised。

  2. SAVEE

    英文,4 个人(男性)的大约 500 个音频,表达了 7 种不同的情绪(第一个字母表示情绪类别):a = anger,d = disgust,f = fear,h = happiness,n = neutral,sa = sadness,su = surprise。

  3. EMO-DB

    德语,10 个人(5 名男性,5 名女性)的大约 500 个音频,表达了 7 种不同的情绪(倒数第二个字母表示情绪类别):N = neutral,W = angry,A = fear,F = happy,T = sad,E = disgust,L = boredom。

  4. CASIA

    汉语,4 个人(2 名男性,2 名女性)的大约 1200 个音频,表达了 6 种不同的情绪:neutral,happy,sad,angry,fearful,surprised。

 

Usage

Prepare

安装依赖:

pip install -r requirements.txt

安装 Opensmile

 

Configuration

configs/ 文件夹中的配置文件(YAML)里配置参数。

其中 Opensmile 标准特征集目前只支持:

如果需要用其他特征集,可以自行修改 extract_feats/opensmile.py 中的 FEATURE_NUM 项。

 

Preprocess

首先需要提取数据集中音频的特征并保存到本地。Opensmile 提取的特征会被保存在 .csv 文件中,librosa 提取的特征会被保存在 .p 文件中。

python preprocess.py --config configs/example.yaml

其中,configs/example.yaml 是你的配置文件路径。

 

Train

数据集路径可以在 configs/ 中配置,相同情感的音频放在同一个文件夹里(可以参考 utils/files.py 整理数据),如:

└── datasets
    ├── angry
    ├── happy
    ├── sad
    ...

然后:

python train.py --config configs/example.yaml

 

Predict

用训练好的模型来预测指定音频的情感。checkpoints 分支release 页面有一些已经训练好的模型。

python predict.py --config configs/example.yaml

 

Functions

Radar Chart

画出预测概率的雷达图。

来源:Radar

from utils.common import Radar
'''
输入:
    data_prob: 概率数组
    class_labels: 情感标签
'''
Radar(data_prob, class_labels)

 

Play Audio

播放一段音频

from utils.common import playAudio
playAudio(file_path)

 

Plot Curve

画训练过程的准确率曲线和损失曲线。

from utils.common import plotCurve
'''
输入:
    train(list): 训练集损失值或准确率数组
    val(list): 验证集损失值或准确率数组
    title(str): 图像标题
    y_label(str): y 轴标签
'''
plotCurve(train, val, title, y_label)

 

Waveform

画出音频的波形图。

from utils.common import Waveform
Waveform(file_path)

 

Spectrogram

画出音频的频谱图。

from utils.common import Spectrogram
Spectrogram(file_path)

 

Other Contributors

speech-emotion-recognition-1's People

Contributors

renovamen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.