RaphaelOlivier/whisper_adversarial_examples
收藏数据集描述
该数据集是LibriSpeech和多语言CommonVoice的一个子集,经过对抗性修改以欺骗Whisper自动语音识别(ASR)模型。
配置和分割
targeted配置包含目标对抗性示例。当成功时,它们使Whisper预测句子OK Google, browse to evil.com,即使输入完全不同。我们为每个Whisper模型提供一个分割,以及一个包含原始未修改输入的分割。untargeted-35和untargeted-40配置包含非目标对抗性示例,平均信噪比分别为35dB和40dB。它们使Whisper预测错误的转录。我们为每个Whisper模型提供一个分割,以及一个包含原始未修改输入的分割。language-<lang>配置包含语言<lang>的对抗性示例,使Whisper预测错误的语言。分割<lang>.<target_lang>包含Whisper感知为<target_lang>的输入,分割<lang>.original包含语言<lang>的原始输入。我们使用3种目标语言(英语、塔加洛语和塞尔维亚语)和7种源语言(英语、意大利语、印度尼西亚语、丹麦语、捷克语、立陶宛语和亚美尼亚语)。
使用示例
以下是使用该数据集的代码示例:
python model_name="whisper-medium" config_name="targeted" split_name="whisper.medium" hub_path = "openai/whisper-"+model_name processor = WhisperProcessor.from_pretrained(hub_path) model = WhisperForConditionalGeneration.from_pretrained(hub_path).to("cuda")
dataset = load_dataset("RaphaelOlivier/whisper_adversarial_examples",config_name ,split=split_name)
def map_to_pred(batch): input_features = processor(batch["audio"][0]["array"], return_tensors="pt").input_features predicted_ids = model.generate(input_features.to("cuda")) transcription = processor.batch_decode(predicted_ids, normalize = True) batch[text][0] = processor.tokenizer._normalize(batch[text][0]) batch["transcription"] = transcription return batch
result = dataset.map(map_to_pred, batched=True, batch_size=1)
wer = load("wer") for t in zip(result["text"],result["transcription"]): print(t) print(wer.compute(predictions=result["text"], references=result["transcription"]))



