语言:
- 英语
- 意大利语
数据集:
- MuST-C
标签:
- 音频
- 语音翻译
- 自动语音识别
许可证: 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-MUSTC-EN-IT-ST
s2t-small-mustc-en-it-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-mustc-en-it-st")
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-mustc-en-it-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=16_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-mustc-en-it-st模型在MuST-C的英语-意大利语子集上进行训练。MuST-C是一个多语言语音翻译语料库,其规模和质量有助于训练从英语到多种语言的端到端语音翻译系统。对于每种目标语言,MuST-C包含数百小时的英语TED演讲音频录音,这些录音在句子级别自动与其手动转录和翻译对齐。
训练过程
预处理
语音数据通过从WAV/FLAC音频文件中自动提取符合Kaldi标准的80通道对数梅尔滤波器组特征进行预处理,使用PyKaldi或torchaudio。此外,对每个样本应用了话语级别的CMVN(倒谱均值和方差归一化)。
文本被转换为小写并使用SentencePiece进行分词,词汇量为8,000。
训练
模型使用标准的自回归交叉熵损失和SpecAugment进行训练。编码器接收语音特征,解码器自回归地生成转录文本。为了加速模型训练并获得更好的性能,编码器在英语ASR任务上进行了预训练。
评估结果
MuST-C测试集上的英语-意大利语翻译结果(BLEU分数):22.7
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},
}