Commit 189edb1b authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Update ASR inference tutorial (#2631)

Summary:
* Use download_asset
* Remove notes around nightly
* Print versions first
* Remove duplicated import

Pull Request resolved: https://github.com/pytorch/audio/pull/2631

Reviewed By: carolineechen

Differential Revision: D38830395

Pulled By: mthrok

fbshipit-source-id: c9259df33562defe249734d1ed074dac0fddc2f6
parent 129a7c1b
...@@ -48,34 +48,22 @@ using CTC loss. ...@@ -48,34 +48,22 @@ using CTC loss.
# working with # working with
# #
import time
from typing import List
import IPython
import matplotlib.pyplot as plt
import torch import torch
import torchaudio import torchaudio
try: print(torch.__version__)
from torchaudio.models.decoder import ctc_decoder print(torchaudio.__version__)
except ModuleNotFoundError:
try:
import google.colab
print( ######################################################################
""" #
To enable running this notebook in Google Colab, install nightly
torch and torchaudio builds by adding the following code block to the top
of the notebook before running it:
!pip3 uninstall -y torch torchvision torchaudio import time
!pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu from typing import List
"""
)
except ModuleNotFoundError:
pass
raise
import IPython
import matplotlib.pyplot as plt
from torchaudio.models.decoder import ctc_decoder
from torchaudio.utils import download_asset
###################################################################### ######################################################################
# Acoustic Model and Data # Acoustic Model and Data
...@@ -97,12 +85,7 @@ acoustic_model = bundle.get_model() ...@@ -97,12 +85,7 @@ acoustic_model = bundle.get_model()
# We will load a sample from the LibriSpeech test-other dataset. # We will load a sample from the LibriSpeech test-other dataset.
# #
hub_dir = torch.hub.get_dir() speech_file = download_asset("tutorial-assets/ctc-decoding/1688-142285-0007.wav")
speech_url = "https://download.pytorch.org/torchaudio/tutorial-assets/ctc-decoding/1688-142285-0007.wav"
speech_file = f"{hub_dir}/speech.wav"
torch.hub.download_url_to_file(speech_url, speech_file)
IPython.display.Audio(speech_file) IPython.display.Audio(speech_file)
...@@ -227,8 +210,6 @@ print(files) ...@@ -227,8 +210,6 @@ print(files)
# `lm` parameter. # `lm` parameter.
# #
from torchaudio.models.decoder import ctc_decoder
LM_WEIGHT = 3.23 LM_WEIGHT = 3.23
WORD_SCORE = -0.26 WORD_SCORE = -0.26
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment