🚀 HIYACCENT:基於對比學習的改進尼日利亞口音語音識別系統
本研究的總體目標是為尼日利亞英語使用者開發一個更強大的模型,這些人的英語發音深受其母語的影響。為此,提出了Wav2Vec - HIYACCENT模型,該模型在新穎的Facebook Wav2vec中引入了一個新層,以捕捉基線模型與尼日利亞英語語音之間的差異。此外,還在模型頂部插入了一個CTC損失函數,為語音 - 文本對齊增加了靈活性。這使得該模型在尼日利亞英語(NAE)語音識別性能上提升了超過20%。
使用UISpeech語料庫在英語上對facebook/wav2vec2 - large進行了微調。使用此模型時,請確保您的語音輸入採樣率為16kHz。
訓練腳本可在此處找到:https://github.com/amceejay/HIYACCENT - NE - Speech - Recognition - System
🚀 快速開始
✨ 主要特性
- 提出Wav2Vec - HIYACCENT模型,引入新層捕捉基線模型與尼日利亞英語語音的差異。
- 在模型頂部插入CTC損失函數,增加語音 - 文本對齊的靈活性。
- 基於UISpeech語料庫對facebook/wav2vec2 - large進行微調,在尼日利亞英語語音識別性能上有顯著提升。
📦 安裝指南
文檔未提及具體安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
使用ASRecognition庫:
from asrecognition import ASREngine
asr = ASREngine("fr", model_path="codeceejay/HIYACCENT_Wav2Vec2")
audio_paths = ["/path/to/file.mp3", "/path/to/another_file.wav"]
transcriptions = asr.transcribe(audio_paths)
高級用法
自行編寫推理腳本:
import torch
import librosa
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
LANG_ID = "en"
MODEL_ID = "codeceejay/HIYACCENT_Wav2Vec2"
SAMPLES = 10
test_dataset = load_dataset("common_voice", LANG_ID, split=f"test[:{SAMPLES}]")
processor = Wav2Vec2Processor.from_pretrained(MODEL_ID)
model = Wav2Vec2ForCTC.from_pretrained(MODEL_ID)
def speech_file_to_array_fn(batch):
speech_array, sampling_rate = librosa.load(batch["path"], sr=16_000)
batch["speech"] = speech_array
batch["sentence"] = batch["sentence"].upper()
return batch
test_dataset = test_dataset.map(speech_file_to_array_fn)
inputs = processor(test_dataset["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
with torch.no_grad():
logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
predicted_ids = torch.argmax(logits, dim=-1)
predicted_sentences = processor.batch_decode(predicted_ids)
for i, predicted_sentence in enumerate(predicted_sentences):
print("-" * 100)
print("Reference:", test_dataset[i]["sentence"])
print("Prediction:", predicted_sentence)
🔧 技術細節
本研究旨在為尼日利亞英語使用者開發更強大的語音識別模型。通過在新穎的Facebook Wav2vec中引入新層,捕捉基線模型與尼日利亞英語語音的差異。同時,在模型頂部插入CTC損失函數,增加語音 - 文本對齊的靈活性,從而使模型在尼日利亞英語語音識別性能上提升超過20%。此外,使用UISpeech語料庫對facebook/wav2vec2 - large進行微調,使用時需確保語音輸入採樣率為16kHz。
📚 詳細文檔
使用此模型時,請確保您的語音輸入採樣率為16kHz。訓練腳本可在此處找到:https://github.com/amceejay/HIYACCENT - NE - Speech - Recognition - System 。
📄 許可證
文檔未提及許可證信息,故跳過此章節。