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
5dcc08f1
Unverified
Commit
5dcc08f1
authored
Mar 16, 2021
by
Lysandre Debut
Committed by
GitHub
Mar 16, 2021
Browse files
Fix S2T example (#10741)
parent
813d730c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
docs/source/model_doc/speech_to_text.rst
docs/source/model_doc/speech_to_text.rst
+3
-3
No files found.
docs/source/model_doc/speech_to_text.rst
View file @
5dcc08f1
...
@@ -58,7 +58,7 @@ be installed as follows: ``apt install libsndfile1-dev``
...
@@ -58,7 +58,7 @@ be installed as follows: ``apt install libsndfile1-dev``
>>> import soundfile as sf
>>> import soundfile as sf
>>> model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr")
>>> model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr")
>>> processor = Speech2Text
p
rocessor.from_pretrained("facebook/s2t-small-librispeech-asr")
>>> processor = Speech2Text
P
rocessor.from_pretrained("facebook/s2t-small-librispeech-asr")
>>> def map_to_array(batch):
>>> def map_to_array(batch):
... speech, _ = sf.read(batch["file"])
... speech, _ = sf.read(batch["file"])
...
@@ -69,7 +69,7 @@ be installed as follows: ``apt install libsndfile1-dev``
...
@@ -69,7 +69,7 @@ be installed as follows: ``apt install libsndfile1-dev``
>>> ds = ds.map(map_to_array)
>>> ds = ds.map(map_to_array)
>>> inputs = processor(ds["speech"][0], sampling_rate=16_000, return_tensors="pt")
>>> inputs = processor(ds["speech"][0], sampling_rate=16_000, return_tensors="pt")
>>> generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask])
>>> generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask
"
])
>>> transcription = processor.batch_decode(generated_ids)
>>> transcription = processor.batch_decode(generated_ids)
...
@@ -90,7 +90,7 @@ be installed as follows: ``apt install libsndfile1-dev``
...
@@ -90,7 +90,7 @@ be installed as follows: ``apt install libsndfile1-dev``
>>> import soundfile as sf
>>> import soundfile as sf
>>> model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-medium-mustc-multilingual-st")
>>> model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-medium-mustc-multilingual-st")
>>> processor = Speech2Text
p
rocessor.from_pretrained("facebook/s2t-medium-mustc-multilingual-st")
>>> processor = Speech2Text
P
rocessor.from_pretrained("facebook/s2t-medium-mustc-multilingual-st")
>>> def map_to_array(batch):
>>> def map_to_array(batch):
... speech, _ = sf.read(batch["file"])
... speech, _ = sf.read(batch["file"])
...
...
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