hubert large speech emotion recognition russian dusha finetuned

提供商xbgoose
分类audio-classification
许可证apache-2.0
下载量251.5K
星标0

简介

这是一个基于 HuBERT-Large 预训练模型、针对俄语语音情感识别(SER)进行微调的专项模型。它专注于从俄语语音片段中提取情绪特征,能够识别说话者的情感状态。对于需要处理俄语音频分析、智能客服情感监控或多语言语音交互的开发者来说,这是一个开箱即用的分类工具。由于继承了 HuBERT 的强大学习能力,该模型在捕捉语音细微波动方面表现出色,上手难度较低,可直接集成到基于 Hugging Face 的音频处理管线中。

核心亮点

  • 专注俄语语音情感识别,捕捉细微情绪波动
  • 基于 HuBERT-Large 架构,特征提取能力强
  • 适用于智能客服、心理分析等音频分类场景
  • 采用 Apache-2.0 协议,商业集成灵活便捷

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned")
tokenizer = AutoTokenizer.from_pretrained("xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned')
tokenizer = AutoTokenizer.from_pretrained('xbgoose/hubert-large-speech-emotion-recognition-russian-dusha-finetuned')

完整文档

来源: HuggingFace

---
language:

  • ru

tags:
  • SER

  • speech

  • audio

  • russian

license: apache-2.0
pipeline_tag: audio-classification
base_model: facebook/hubert-large-ls960-ft
datasets:
  • xbgoose/dusha

---

HuBERT fine-tuned on DUSHA dataset for speech emotion recognition in russian language

The pre-trained model is this one - facebook/hubert-large-ls960-ft

The DUSHA dataset used can be found here

Fine-tuning

Fine-tuned in Google Colab using Pro account with A100 GPU

Freezed all layers exept projector, classifier and all 24 HubertEncoderLayerStableLayerNorm layers

Used half of the train dataset

Training parameters

  • 2 epochs
  • train batch size = 8
  • eval batch size = 8
  • gradient accumulation steps = 4
  • learning rate = 5e-5 without warm up and decay

Metrics

Achieved

  • accuracy = 0.86

  • balanced = 0.76

  • macro f1 score = 0.81

on test set, improving accucary and f1 score compared to dataset baseline

Usage

python
from transformers import HubertForSequenceClassification, Wav2Vec2FeatureExtractor
import torchaudio
import torch

feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("facebook/hubert-large-ls960-ft")
model = HubertForSequenceClassification.from_pretrained("xbgoose/hubert-speech-emotion-recognition-russian-dusha-finetuned")
num2emotion = {0: 'neutral', 1: 'angry', 2: 'positive', 3: 'sad', 4: 'other'}

filepath = "path/to/audio.wav"

waveform, sample_rate = torchaudio.load(filepath, normalize=True)
transform = torchaudio.transforms.Resample(sample_rate, 16000)
waveform = transform(waveform)

inputs = feature_extractor(
waveform,
sampling_rate=feature_extractor.sampling_rate,
return_tensors="pt",
padding=True,
max_length=16000 * 10,
truncation=True
)

logits = model(inputs['input_values'][0]).logits
predictions = torch.argmax(logits, dim=-1)
predicted_emotion = num2emotion[predictions.numpy()[0]]
print(predicted_emotion)