language: zh
datasets:
- superb
tags:
- 语音
- 音频分类
- hubert
license: apache-2.0
用于意图分类的Hubert-Base模型
模型描述
这是S3PRL的Hubert模型在SUPERB意图分类任务上的移植版本。
基础模型为hubert-base-ls960,该模型基于16kHz采样的语音音频进行预训练。使用时请确保输入语音同样以16kHz采样。
更多信息请参考SUPERB:语音处理通用性能基准
任务与数据集说明
意图分类(IC)将话语归类至预定义的类别,以确定说话者的意图。SUPERB采用流利语音命令数据集,每条话语标注有三个意图标签:动作、对象和位置。
原始模型的训练与评估方法请参阅S3PRL下游任务说明。
使用示例
可直接按以下方式使用模型:
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", "ic", split="test")
dataset = dataset.map(map_to_array)
model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-ic")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-ic")
inputs = feature_extractor(dataset[:4]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
logits = model(**inputs).logits
action_ids = torch.argmax(logits[:, :6], dim=-1).tolist()
action_labels = [model.config.id2label[_id] for _id in action_ids]
object_ids = torch.argmax(logits[:, 6:20], dim=-1).tolist()
object_labels = [model.config.id2label[_id + 6] for _id in object_ids]
location_ids = torch.argmax(logits[:, 20:24], dim=-1).tolist()
location_labels = [model.config.id2label[_id + 20] for _id in location_ids]
评估结果
评估指标为准确率。
|
s3prl |
transformers |
测试集 |
0.9834 |
N/A |
BibTeX条目及引用信息
@article{yang2021superb,
title={SUPERB:语音处理通用性能基准},
author={杨书文 and 纪柏涵 and 庄永松 and 赖正一 and 拉科蒂亚 and 林毅 and 刘安迪 and 石家彤 and 常轩凯 and 林冠廷等},
journal={arXiv预印本 arXiv:2105.01051},
year={2021}
}