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
371fb0b7
Unverified
Commit
371fb0b7
authored
Dec 13, 2023
by
Arthur
Committed by
GitHub
Dec 13, 2023
Browse files
[`Whisper`] raise better errors (#27971)
* [`Whisper`] raise better erros fixes #27893 * update torch as well
parent
230ac352
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
src/transformers/models/whisper/modeling_tf_whisper.py
src/transformers/models/whisper/modeling_tf_whisper.py
+5
-0
src/transformers/models/whisper/modeling_whisper.py
src/transformers/models/whisper/modeling_whisper.py
+5
-0
No files found.
src/transformers/models/whisper/modeling_tf_whisper.py
View file @
371fb0b7
...
...
@@ -1495,6 +1495,11 @@ class TFWhisperForConditionalGeneration(TFWhisperPreTrainedModel, TFCausalLangua
f
"Unsupported language:
{
generation_config
.
language
}
. Language should be one of:"
f
"
{
list
(
TO_LANGUAGE_CODE
.
values
())
if
is_language_code
else
list
(
TO_LANGUAGE_CODE
.
keys
())
}
."
)
if
language_token
not
in
generation_config
.
lang_to_id
:
raise
ValueError
(
f
"
{
language_token
}
is not supported by this specific model as it is not in the `generation_config.lang_to_id`."
"(You should just add it to the generation config)"
)
forced_decoder_ids
.
append
((
1
,
generation_config
.
lang_to_id
[
language_token
]))
else
:
forced_decoder_ids
.
append
((
1
,
None
))
# automatically detect the language
...
...
src/transformers/models/whisper/modeling_whisper.py
View file @
371fb0b7
...
...
@@ -2158,6 +2158,11 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
f
"Unsupported language:
{
generation_config
.
language
}
. Language should be one of:"
f
"
{
list
(
TO_LANGUAGE_CODE
.
values
())
if
is_language_code
else
list
(
TO_LANGUAGE_CODE
.
keys
())
}
."
)
if
language_token
not
in
generation_config
.
lang_to_id
:
raise
ValueError
(
f
"
{
language_token
}
is not supported by this specific model as it is not in the `generation_config.lang_to_id`."
"(You should just add it to the generation config)"
)
forced_decoder_ids
.
append
((
1
,
generation_config
.
lang_to_id
[
language_token
]))
else
:
forced_decoder_ids
.
append
((
1
,
None
))
# automatically detect the language
...
...
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