英文

S2T2-Wav2Vec2-CoVoST2-EN-TR-ST

s2t-wav2vec2-large-en-tr 是一个用于端到端语音翻译(ST)的语音到文本转换模型。S2T2 模型是在 Large-Scale Self- and Semi-Supervised Learning for Speech Translation 中提出的,并在 Fairseq 中正式发布。

模型描述

S2T2 是一个基于 Transformer 的 seq2seq(语音编码器-解码器)模型,旨在进行端到端的自动语音识别(ASR)和语音翻译(ST)任务。它使用预训练的 Wav2Vec2 作为编码器和基于 Transformer 的解码器。该模型通过标准的自回归交叉熵损失进行训练,并自回归地生成翻译文本。

使用和限制

该模型可用于将英语语音转换为土耳其文本。可以查看 model hub 以查找其他 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-tr", feature_extractor="facebook/s2t-wav2vec2-large-en-tr")

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-tr")
processor = Speech2Text2Processor.from_pretrained("facebook/s2t-wav2vec2-large-en-tr")

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)

评估结果

en-tr 的 CoVoST-V2 测试结果(BLEU 分数)为 17.5。

更多信息,请查看 official paper ,特别是表 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}
}