🚀 用於關鍵詞檢測的Hubert-Large模型
本模型是用於關鍵詞檢測的Hubert-Large版本,基於Transformer架構,能夠高效準確地識別語音中的關鍵詞,為語音交互等應用提供強大支持。
🚀 快速開始
本模型可通過音頻分類管道使用,也可直接調用模型進行推理。使用時請確保輸入語音的採樣率為16kHz。
✨ 主要特性
- 精準識別:基於預訓練的hubert-large-ll60k模型,在關鍵詞檢測任務上表現出色。
- 適配標準數據集:使用廣泛應用的Speech Commands數據集v1.0進行訓練和評估。
- 多方式調用:支持通過音頻分類管道和直接調用模型兩種方式使用。
📦 安裝指南
文檔未提及安裝步驟,可參考相關庫(如datasets
、transformers
、torch
、torchaudio
等)的官方安裝指南進行安裝。
💻 使用示例
基礎用法
你可以通過音頻分類管道使用該模型:
from datasets import load_dataset
from transformers import pipeline
dataset = load_dataset("anton-l/superb_demo", "ks", split="test")
classifier = pipeline("audio-classification", model="superb/hubert-large-superb-ks")
labels = classifier(dataset[0]["file"], top_k=5)
高級用法
也可以直接使用該模型:
import torch
from datasets import load_dataset
from transformers import HubertForSequenceClassification, Wav2Vec2FeatureExtractor
from torchaudio.sox_effects import apply_effects_file
effects = [["channels", "1"], ["rate", "16000"], ["gain", "-3.0"]]
def map_to_array(example):
speech, _ = apply_effects_file(example["file"], effects)
example["speech"] = speech.squeeze(0).numpy()
return example
dataset = load_dataset("anton-l/superb_demo", "ks", split="test")
dataset = dataset.map(map_to_array)
model = HubertForSequenceClassification.from_pretrained("superb/hubert-large-superb-ks")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-large-superb-ks")
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的Hubert用於SUPERB關鍵詞檢測任務 的移植版本。
基礎模型是 hubert-large-ll60k,它在16kHz採樣的語音音頻上進行了預訓練。使用該模型時,請確保你的語音輸入也是16kHz採樣的。
更多信息請參考 SUPERB: 語音處理通用性能基準。
任務和數據集描述
關鍵詞檢測(KS)通過將語音分類到預定義的單詞集合中來檢測預註冊的關鍵詞。該任務通常在設備上執行以實現快速響應時間。因此,準確性、模型大小和推理時間都至關重要。SUPERB使用廣泛應用的 Speech Commands數據集v1.0 來完成此任務。
該數據集由十個關鍵詞類、一個靜音類和一個用於包含誤報的未知類組成。
有關原始模型的訓練和評估說明,請參考 S3PRL下游任務README。
評估結果
評估指標為準確率。
|
s3prl |
transformers |
測試集 |
0.9529 |
0.9532 |
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許可證。