英文

S2T-SMALL-MUSTC-EN-DE-ST

s2t-small-mustc-en-de-st是一种用于端到端语音翻译(ST)的语音到文本转换(S2T)模型。S2T模型是在 this paper 中提出并在 this repository 中发布的。

模型描述

S2T是一种基于Transformer的序列到序列(编码器-解码器)模型,专为端到端的自动语音识别(ASR)和语音翻译(ST)而设计。它使用卷积降采样器将语音输入的长度减小3/4,然后将其输入编码器。该模型使用标准的自回归交叉熵损失进行训练,并自回归地生成转录/翻译。

预期用途和限制

该模型可用于将英语语音端到端翻译为德语文本。请参阅 model hub 以查找其他S2T检查点。

如何使用

由于这是一个标准的序列到序列变换器模型,您可以使用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-de-st")
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-mustc-en-de-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-de-st是在 MuST-C 的英德子集上进行训练的。MuST-C是一个多语言语音翻译语料库,其规模和质量有助于训练从英语到多种语言的端到端语音翻译系统。对于每种目标语言,MuST-C包括来自英语TED演讲的数百小时音频记录,这些记录在句子级别自动对齐其手动转录和翻译。

训练过程

预处理

语音数据通过使用PyKaldi或torchaudio从WAV/FLAC音频文件自动提取符合Kaldi标准的80通道对数梅尔滤波器组特征进行预处理。进一步,对每个示例应用基于句子的CMVN(倒谱均值和方差归一化)。

文本以小写形式表示,并使用SentencePiece和8000个词汇大小进行标记化。

训练

该模型使用标准自回归交叉熵损失进行训练,并使用 SpecAugment 。编码器接收语音特征,解码器自回归生成转录。为了加快模型训练和提高性能,编码器还进行了英语ASR的预训练。

评估结果

en-de的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},
}