语言:
- 英语
- 加泰罗尼亚语
数据集:
- covost2
标签:
- 音频
- 语音翻译
- 自动语音识别
许可证: mit
管道标签: 自动语音识别
小部件:
- 示例标题: Librispeech 样本1
来源: https://cdn-media.huggingface.co/speech_samples/sample1.flac
- 示例标题: Librispeech 样本2
来源: https://cdn-media.huggingface.co/speech_samples/sample2.flac
S2T-SMALL-COVOST2-EN-CA-ST
s2t-small-covost2-en-ca-st
是一个专为端到端语音翻译(ST)训练的语音到文本转换器(S2T)模型。该S2T模型在这篇论文中提出,并在此代码库中发布。
模型描述
S2T是一个基于Transformer的序列到序列(编码器-解码器)模型,专为端到端自动语音识别(ASR)和语音翻译(ST)设计。它使用卷积下采样器在语音输入进入编码器之前将其长度减少3/4。模型通过标准的自回归交叉熵损失进行训练,并自回归生成转录/翻译文本。
预期用途与限制
该模型可用于端到端的英语语音到加泰罗尼亚语文本翻译。查看模型中心以寻找其他S2T检查点。
使用方法
由于这是一个标准的序列到序列Transformer模型,您可以使用generate
方法通过将语音特征传递给模型来生成转录文本。
注意:Speech2TextProcessor
对象使用torchaudio提取滤波器组特征。在运行此示例前,请确保安装了torchaudio
包。
您可以通过pip install transformers"[speech, sentencepiece]"
安装这些额外的语音依赖项,或者单独安装这些包:pip install torchaudio sentencepiece
。
import torch
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
from datasets import load_dataset
import soundfile as sf
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-covost2-en-ca-st")
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-covost2-en-ca-st")
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=48_000,
return_tensors="pt"
)
generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask"])
translation = processor.batch_decode(generated_ids, skip_special_tokens=True)
训练数据
s2t-small-covost2-en-ca-st模型在CoVoST2的英语-加泰罗尼亚语子集上进行训练。CoVoST是一个基于Common Voice的大规模多语言语音翻译语料库,旨在通过有史以来最大的开放数据集促进语音翻译研究。
训练过程
预处理
语音数据通过从WAV/FLAC音频文件中自动提取符合Kaldi标准的80通道对数梅尔滤波器组特征进行预处理,使用PyKaldi或torchaudio。进一步对每个样本应用话语级别的CMVN(倒谱均值和方差归一化)。
文本通过基于字符的SentencePiece词汇表进行小写和分词处理。
训练
模型使用标准的自回归交叉熵损失和SpecAugment进行训练。编码器接收语音特征,解码器自回归生成转录文本。为了加速模型训练并获得更好的性能,编码器在英语自动语音识别任务上进行了预训练。
评估结果
CoVOST2测试集上英语-加泰罗尼亚语的BLEU分数为:21.68。
BibTeX条目与引用信息
@inproceedings{wang2020fairseqs2t,
title = {fairseq S2T: Fast Speech-to-Text Modeling with fairseq},
author = {Changhan Wang and Yun Tang and Xutai Ma and Anne Wu and Dmytro Okhonko and Juan Pino},
booktitle = {Proceedings of the 2020 Conference of the Asian Chapter of the Association for Computational Linguistics (AACL): System Demonstrations},
year = {2020},
}