Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
a57d784d
Unverified
Commit
a57d784d
authored
Sep 10, 2021
by
Patrick von Platen
Committed by
GitHub
Sep 10, 2021
Browse files
[Wav2Vec2] Fix dtype 64 bug (#13517)
* fix * 2nd fix
parent
72ec2f3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
src/transformers/models/speech_to_text/feature_extraction_speech_to_text.py
...odels/speech_to_text/feature_extraction_speech_to_text.py
+1
-1
src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py
...ansformers/models/wav2vec2/feature_extraction_wav2vec2.py
+2
-2
No files found.
src/transformers/models/speech_to_text/feature_extraction_speech_to_text.py
View file @
a57d784d
...
@@ -210,7 +210,7 @@ class Speech2TextFeatureExtractor(SequenceFeatureExtractor):
...
@@ -210,7 +210,7 @@ class Speech2TextFeatureExtractor(SequenceFeatureExtractor):
raw_speech
=
[
np
.
asarray
(
speech
)
for
speech
in
raw_speech
]
raw_speech
=
[
np
.
asarray
(
speech
)
for
speech
in
raw_speech
]
elif
not
is_batched
and
not
isinstance
(
raw_speech
,
np
.
ndarray
):
elif
not
is_batched
and
not
isinstance
(
raw_speech
,
np
.
ndarray
):
raw_speech
=
np
.
asarray
(
raw_speech
)
raw_speech
=
np
.
asarray
(
raw_speech
)
elif
isinstance
(
raw_speech
,
np
.
ndarray
)
and
raw_speech
.
dtype
is
np
.
float64
:
elif
isinstance
(
raw_speech
,
np
.
ndarray
)
and
raw_speech
.
dtype
is
np
.
dtype
(
np
.
float64
)
:
raw_speech
=
raw_speech
.
astype
(
np
.
float32
)
raw_speech
=
raw_speech
.
astype
(
np
.
float32
)
# always return batch
# always return batch
...
...
src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py
View file @
a57d784d
...
@@ -207,10 +207,10 @@ class Wav2Vec2FeatureExtractor(SequenceFeatureExtractor):
...
@@ -207,10 +207,10 @@ class Wav2Vec2FeatureExtractor(SequenceFeatureExtractor):
elif
(
elif
(
not
isinstance
(
input_values
,
np
.
ndarray
)
not
isinstance
(
input_values
,
np
.
ndarray
)
and
isinstance
(
input_values
[
0
],
np
.
ndarray
)
and
isinstance
(
input_values
[
0
],
np
.
ndarray
)
and
input_values
[
0
].
dtype
is
np
.
float64
and
input_values
[
0
].
dtype
is
np
.
dtype
(
np
.
float64
)
):
):
padded_inputs
[
"input_values"
]
=
[
array
.
astype
(
np
.
float32
)
for
array
in
input_values
]
padded_inputs
[
"input_values"
]
=
[
array
.
astype
(
np
.
float32
)
for
array
in
input_values
]
elif
isinstance
(
input_values
,
np
.
ndarray
)
and
input_values
.
dtype
is
np
.
float64
:
elif
isinstance
(
input_values
,
np
.
ndarray
)
and
input_values
.
dtype
is
np
.
dtype
(
np
.
float64
)
:
padded_inputs
[
"input_values"
]
=
input_values
.
astype
(
np
.
float32
)
padded_inputs
[
"input_values"
]
=
input_values
.
astype
(
np
.
float32
)
# convert attention_mask to correct format
# convert attention_mask to correct format
...
...
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