Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
d9e693e1
Unverified
Commit
d9e693e1
authored
Mar 15, 2021
by
Patrick von Platen
Committed by
GitHub
Mar 15, 2021
Browse files
make wav2vec2 test deterministic (#10714)
parent
6bef7645
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
tests/test_modeling_wav2vec2.py
tests/test_modeling_wav2vec2.py
+4
-1
No files found.
tests/test_modeling_wav2vec2.py
View file @
d9e693e1
...
@@ -515,6 +515,8 @@ class Wav2Vec2ModelIntegrationTest(unittest.TestCase):
...
@@ -515,6 +515,8 @@ class Wav2Vec2ModelIntegrationTest(unittest.TestCase):
import
soundfile
as
sf
import
soundfile
as
sf
ids
=
[
f
"1272-141231-000
{
i
}
"
for
i
in
range
(
num_samples
)]
# map files to raw
# map files to raw
def
map_to_array
(
batch
):
def
map_to_array
(
batch
):
speech
,
_
=
sf
.
read
(
batch
[
"file"
])
speech
,
_
=
sf
.
read
(
batch
[
"file"
])
...
@@ -522,7 +524,8 @@ class Wav2Vec2ModelIntegrationTest(unittest.TestCase):
...
@@ -522,7 +524,8 @@ class Wav2Vec2ModelIntegrationTest(unittest.TestCase):
return
batch
return
batch
ds
=
load_dataset
(
"patrickvonplaten/librispeech_asr_dummy"
,
"clean"
,
split
=
"validation"
)
ds
=
load_dataset
(
"patrickvonplaten/librispeech_asr_dummy"
,
"clean"
,
split
=
"validation"
)
ds
=
ds
.
select
(
range
(
num_samples
)).
map
(
map_to_array
)
ds
=
ds
.
filter
(
lambda
x
:
x
[
"id"
]
in
ids
).
sort
(
"id"
).
map
(
map_to_array
)
return
ds
[
"speech"
][:
num_samples
]
return
ds
[
"speech"
][:
num_samples
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment