🚀 用於情感識別的Hubert-Base
本模型是基於Hubert的情感識別模型,以hubert-base-ls960為基礎模型,在16kHz採樣的語音音頻上預訓練,可用於預測每個語音片段的情感類別。
🚀 快速開始
本模型是 S3PRL的Hubert用於SUPERB情感識別任務 的移植版本。
基礎模型是 hubert-base-ls960,它在16kHz採樣的語音音頻上進行了預訓練。使用該模型時,請確保您的語音輸入也是16kHz採樣的。
更多信息請參考 SUPERB:語音處理通用性能基準。
✨ 主要特性
情感識別(ER)為每個語音片段預測一個情感類別。本模型採用了最廣泛使用的ER數據集 IEMOCAP,並遵循傳統的評估協議:我們去除了不平衡的情感類別,最終保留四個數據點數量相近的類別,並在標準分割的五個折上進行交叉驗證。
有關原始模型的訓練和評估說明,請參考 S3PRL下游任務README。
💻 使用示例
基礎用法
您可以通過音頻分類管道使用該模型:
from datasets import load_dataset
from transformers import pipeline
dataset = load_dataset("anton-l/superb_demo", "er", split="session1")
classifier = pipeline("audio-classification", model="superb/hubert-base-superb-er")
labels = classifier(dataset[0]["file"], top_k=5)
高級用法
或者直接使用該模型:
import torch
import librosa
from datasets import load_dataset
from transformers import HubertForSequenceClassification, Wav2Vec2FeatureExtractor
def map_to_array(example):
speech, _ = librosa.load(example["file"], sr=16000, mono=True)
example["speech"] = speech
return example
dataset = load_dataset("anton-l/superb_demo", "er", split="session1")
dataset = dataset.map(map_to_array)
model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-er")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-er")
inputs = feature_extractor(dataset[:4]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
logits = model(**inputs).logits
predicted_ids = torch.argmax(logits, dim=-1)
labels = [model.config.id2label[_id] for _id in predicted_ids.tolist()]
📚 詳細文檔
評估結果
評估指標為準確率。
|
s3prl |
transformers |
session1 |
0.6492 |
0.6359 |
BibTeX引用和引用信息
@article{yang2021superb,
title={SUPERB: Speech processing Universal PERformance Benchmark},
author={Yang, Shu-wen and Chi, Po-Han and Chuang, Yung-Sung and Lai, Cheng-I Jeff and Lakhotia, Kushal and Lin, Yist Y and Liu, Andy T and Shi, Jiatong and Chang, Xuankai and Lin, Guan-Ting and others},
journal={arXiv preprint arXiv:2105.01051},
year={2021}
}
📄 許可證
本模型使用的許可證為 apache-2.0
。