🚀 S2T2-Wav2Vec2-CoVoST2-EN-AR-ST
s2t-wav2vec2-large-en-ar
是一個用於端到端語音翻譯(ST)的語音轉文本Transformer模型。S2T2模型在論文 Large-Scale Self- and Semi-Supervised Learning for Speech Translation 中被提出,並在 Fairseq 中正式發佈。
🚀 快速開始
本模型可用於端到端的英語語音到阿拉伯語文本的翻譯。你可以在 模型中心 查找其他S2T2的檢查點。
如何使用
由於這是一個標準的序列到序列Transformer模型,你可以通過將語音特徵傳遞給模型,使用 generate
方法生成轉錄內容。
你可以通過自動語音識別(ASR)管道直接使用該模型:
from datasets import load_dataset
from transformers import pipeline
librispeech_en = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
asr = pipeline("automatic-speech-recognition", model="facebook/s2t-wav2vec2-large-en-ar", feature_extractor="facebook/s2t-wav2vec2-large-en-ar")
translation = asr(librispeech_en[0]["file"])
或者按以下步驟逐步使用:
import torch
from transformers import Speech2Text2Processor, SpeechEncoderDecoder
from datasets import load_dataset
import soundfile as sf
model = SpeechEncoderDecoder.from_pretrained("facebook/s2t-wav2vec2-large-en-ar")
processor = Speech2Text2Processor.from_pretrained("facebook/s2t-wav2vec2-large-en-ar")
def map_to_array(batch):
speech, _ = sf.read(batch["file"])
batch["speech"] = speech
return batch
ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
ds = ds.map(map_to_array)
inputs = processor(ds["speech"][0], sampling_rate=16_000, return_tensors="pt")
generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask"])
transcription = processor.batch_decode(generated_ids)
✨ 主要特性
S2T2是一個基於Transformer的序列到序列(語音編碼器 - 解碼器)模型,專為端到端的自動語音識別(ASR)和語音翻譯(ST)而設計。它使用預訓練的 Wav2Vec2 作為編碼器,並採用基於Transformer的解碼器。該模型使用標準的自迴歸交叉熵損失進行訓練,並以自迴歸的方式生成翻譯內容。
📚 詳細文檔
評估結果
CoVoST-V2 英語到阿拉伯語的測試結果(BLEU分數):20.2
更多信息,請查看 官方論文 —— 特別是表2的第10行。
BibTeX引用和引用信息
@article{DBLP:journals/corr/abs-2104-06678,
author = {Changhan Wang and
Anne Wu and
Juan Miguel Pino and
Alexei Baevski and
Michael Auli and
Alexis Conneau},
title = {Large-Scale Self- and Semi-Supervised Learning for Speech Translation},
journal = {CoRR},
volume = {abs/2104.06678},
year = {2021},
url = {https://arxiv.org/abs/2104.06678},
archivePrefix = {arXiv},
eprint = {2104.06678},
timestamp = {Thu, 12 Aug 2021 15:37:06 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-2104-06678.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
📄 許可證
本項目採用MIT許可證。
📦 相關信息
屬性 |
詳情 |
支持語言 |
英語、阿拉伯語 |
數據集 |
covost2、librispeech_asr |
標籤 |
音頻、語音翻譯、自動語音識別、speech2text2 |
任務類型 |
自動語音識別 |