Commit
·
64ab7b9
1
Parent(s):
987c1d3
Update whisper_adversarial_examples.py
Browse files- whisper_adversarial_examples.py +17 -28
whisper_adversarial_examples.py
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
# limitations under the License.
|
15 |
|
16 |
# Lint as: python3
|
17 |
-
"""
|
18 |
|
19 |
|
20 |
import os
|
@@ -23,17 +23,6 @@ import datasets
|
|
23 |
from datasets.tasks import AutomaticSpeechRecognition
|
24 |
|
25 |
|
26 |
-
_CITATION = """\
|
27 |
-
@inproceedings{panayotov2015librispeech,
|
28 |
-
title={Librispeech: an ASR corpus based on public domain audio books},
|
29 |
-
author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
|
30 |
-
booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},
|
31 |
-
pages={5206--5210},
|
32 |
-
year={2015},
|
33 |
-
organization={IEEE}
|
34 |
-
}
|
35 |
-
"""
|
36 |
-
|
37 |
_DESCRIPTION = """\
|
38 |
Adversarial examples fooling whisper models
|
39 |
"""
|
@@ -73,8 +62,8 @@ _DL_URLS = {
|
|
73 |
}
|
74 |
|
75 |
|
76 |
-
class
|
77 |
-
"""BuilderConfig for
|
78 |
|
79 |
def __init__(self, **kwargs):
|
80 |
"""
|
@@ -85,25 +74,25 @@ class LibrispeechASRConfig(datasets.BuilderConfig):
|
|
85 |
url: `string`, url for information about the data set
|
86 |
**kwargs: keyword arguments forwarded to super.
|
87 |
"""
|
88 |
-
super(
|
89 |
|
90 |
|
91 |
-
class
|
92 |
-
"""
|
93 |
|
94 |
DEFAULT_WRITER_BATCH_SIZE = 256
|
95 |
DEFAULT_CONFIG_NAME = "all"
|
96 |
BUILDER_CONFIGS = [
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
]
|
108 |
|
109 |
def _info(self):
|
@@ -207,7 +196,7 @@ class LibrispeechASR(datasets.GeneratorBasedBuilder):
|
|
207 |
return splits
|
208 |
|
209 |
def _generate_examples(self, files, local_extracted_archive,path_audio):
|
210 |
-
"""Generate examples from
|
211 |
key = 0
|
212 |
audio_data = {}
|
213 |
transcripts = []
|
|
|
14 |
# limitations under the License.
|
15 |
|
16 |
# Lint as: python3
|
17 |
+
"""Adversarial examples against Whisper"""
|
18 |
|
19 |
|
20 |
import os
|
|
|
23 |
from datasets.tasks import AutomaticSpeechRecognition
|
24 |
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
_DESCRIPTION = """\
|
27 |
Adversarial examples fooling whisper models
|
28 |
"""
|
|
|
62 |
}
|
63 |
|
64 |
|
65 |
+
class AdvWhisperASRConfig(datasets.BuilderConfig):
|
66 |
+
"""BuilderConfig for AdvWhisperASR."""
|
67 |
|
68 |
def __init__(self, **kwargs):
|
69 |
"""
|
|
|
74 |
url: `string`, url for information about the data set
|
75 |
**kwargs: keyword arguments forwarded to super.
|
76 |
"""
|
77 |
+
super(AdvWhisperASRConfig, self).__init__(version=datasets.Version("0.1.0", ""), **kwargs)
|
78 |
|
79 |
|
80 |
+
class AdvWhisperASR(datasets.GeneratorBasedBuilder):
|
81 |
+
"""whisper_adversarial_examples dataset."""
|
82 |
|
83 |
DEFAULT_WRITER_BATCH_SIZE = 256
|
84 |
DEFAULT_CONFIG_NAME = "all"
|
85 |
BUILDER_CONFIGS = [
|
86 |
+
AdvWhisperASRConfig(name="targeted", description="Targeted adversarial examples, with target 'OK Google, browse to evil.com'"),
|
87 |
+
AdvWhisperASRConfig(name="untargeted-35", description="Untargeted adversarial examples of radius approximately 35dB"),
|
88 |
+
AdvWhisperASRConfig(name="untargeted-40", description="Untargeted adversarial examples of radius approximately 40dB"),
|
89 |
+
AdvWhisperASRConfig(name="language-armenian", description="Adversarial examples generated by fooling the whisper language detection module. The true language is Armenian"),
|
90 |
+
AdvWhisperASRConfig(name="language-lithuanian", description="Adversarial examples generated by fooling the whisper language detection module. The true language is Lithuanian"),
|
91 |
+
AdvWhisperASRConfig(name="language-czech", description="Adversarial examples generated by fooling the whisper language detection module. The true language is Czech"),
|
92 |
+
AdvWhisperASRConfig(name="language-danish", description="Adversarial examples generated by fooling the whisper language detection module. The true language is Danish"),
|
93 |
+
AdvWhisperASRConfig(name="language-indonesian", description="Adversarial examples generated by fooling the whisper language detection module. The true language is Indonesian"),
|
94 |
+
AdvWhisperASRConfig(name="language-italian", description="Adversarial examples generated by fooling the whisper language detection module. The true language is Italian"),
|
95 |
+
AdvWhisperASRConfig(name="language-english", description="Adversarial examples generated by fooling the whisper language detection module. The true language is English")
|
96 |
]
|
97 |
|
98 |
def _info(self):
|
|
|
196 |
return splits
|
197 |
|
198 |
def _generate_examples(self, files, local_extracted_archive,path_audio):
|
199 |
+
"""Generate examples from an extracted path."""
|
200 |
key = 0
|
201 |
audio_data = {}
|
202 |
transcripts = []
|