language: zh
datasets:
- superb
tags:
- 语音
- 音频
- wav2vec2
- 音频分类
license: apache-2.0
widget:
- example_title: VoxCeleb 说话人 id10003
src: https://cdn-media.huggingface.co/speech_samples/VoxCeleb1_00003.wav
- example_title: VoxCeleb 说话人 id10004
src: https://cdn-media.huggingface.co/speech_samples/VoxCeleb_00004.wav
用于说话人识别的 Wav2Vec2-Large 模型
模型描述
这是 S3PRL 的 Wav2Vec2 模型 在 SUPERB 说话人识别任务上的移植版本。
基础模型是 wav2vec2-large-lv60,该模型在 16kHz 采样的语音音频上进行了预训练。使用该模型时,请确保您的语音输入也以 16kHz 采样。
更多信息请参考 SUPERB: 语音处理通用性能基准
任务和数据集描述
说话人识别(SI)将每个话语按其说话人身份进行分类,作为一个多类别分类问题,其中训练和测试使用的说话人集合是相同的。广泛使用的 VoxCeleb1 数据集被采用。
关于原始模型的训练和评估说明,请参考 S3PRL 下游任务 README。
使用示例
您可以通过音频分类管道使用该模型:
from datasets import load_dataset
from transformers import pipeline
dataset = load_dataset("anton-l/superb_demo", "si", split="test")
classifier = pipeline("audio-classification", model="superb/wav2vec2-large-superb-sid")
labels = classifier(dataset[0]["file"], top_k=5)
或者直接使用模型:
import torch
import librosa
from datasets import load_dataset
from transformers import Wav2Vec2ForSequenceClassification, 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", "si", split="test")
dataset = dataset.map(map_to_array)
model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-large-superb-sid")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-large-superb-sid")
inputs = feature_extractor(dataset[:2]["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 |
test |
0.8614 |
0.8613 |
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}
}