Commit fb51cecc authored by hwangjeff's avatar hwangjeff Committed by Facebook GitHub Bot
Browse files

Add nightly build installation code snippet to prototype feature tutorials (#2325)

Summary:
Tutorial notebooks that leverage TorchAudio prototype features don't run as-is on Google Colab due to its runtime's not having nightly builds pre-installed. To make it easier for users to run said notebooks in Colab, this PR adds a code block that installs nightly Pytorch and TorchAudio builds as a comment that users can copy and run locally.

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

Reviewed By: xiaohui-zhang

Differential Revision: D35597753

Pulled By: hwangjeff

fbshipit-source-id: 59914e492ad72e31c0136a48cd88d697e8ea5f6c
parent b0c8e239
...@@ -72,6 +72,26 @@ import matplotlib.pyplot as plt ...@@ -72,6 +72,26 @@ import matplotlib.pyplot as plt
import torch import torch
import torchaudio import torchaudio
try:
import torchaudio.prototype.ctc_decoder
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
!pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
"""
)
except ModuleNotFoundError:
pass
raise
###################################################################### ######################################################################
# Acoustic Model and Data # Acoustic Model and Data
......
...@@ -10,7 +10,7 @@ on laptop. ...@@ -10,7 +10,7 @@ on laptop.
.. note:: .. note::
This tutorial requires prototype Streaming API and ffmpeg>=4.1. This tutorial requires prototype Streaming API, ffmpeg>=4.1, and SentencePiece.
Prototype features are not part of binary releases, but available in Prototype features are not part of binary releases, but available in
nightly build. Please refer to https://pytorch.org for installing nightly build. Please refer to https://pytorch.org for installing
...@@ -20,6 +20,8 @@ on laptop. ...@@ -20,6 +20,8 @@ on laptop.
``conda install -c anaconda ffmpeg`` will install ``conda install -c anaconda ffmpeg`` will install
the required libraries. the required libraries.
You can install SentencePiece by running ``pip install sentencepiece``.
.. note:: .. note::
This tutorial was tested on MacBook Pro and Dynabook with Windows 10. This tutorial was tested on MacBook Pro and Dynabook with Windows 10.
......
...@@ -13,8 +13,8 @@ to perform online speech recognition. ...@@ -13,8 +13,8 @@ to perform online speech recognition.
# #
# .. note:: # .. note::
# #
# This tutorial requires torchaudio with prototype features and # This tutorial requires torchaudio with prototype features,
# FFmpeg libraries (>=4.1). # FFmpeg libraries (>=4.1), and SentencePiece.
# #
# torchaudio prototype features are available on nightly builds. # torchaudio prototype features are available on nightly builds.
# Please refer to https://pytorch.org/get-started/locally/ # Please refer to https://pytorch.org/get-started/locally/
...@@ -30,13 +30,7 @@ to perform online speech recognition. ...@@ -30,13 +30,7 @@ to perform online speech recognition.
# ``conda install -c anaconda ffmpeg`` will install # ``conda install -c anaconda ffmpeg`` will install
# the required libraries. # the required libraries.
# #
# When running this tutorial in Google Colab, the following # You can install SentencePiece by running ``pip install sentencepiece``.
# command should do.
#
# .. code::
#
# !add-apt-repository -y ppa:savoury1/ffmpeg4
# !apt-get -qq install -y ffmpeg
###################################################################### ######################################################################
# 1. Overview # 1. Overview
...@@ -59,10 +53,32 @@ import IPython ...@@ -59,10 +53,32 @@ import IPython
import torch import torch
import torchaudio import torchaudio
try:
from torchaudio.prototype.io import Streamer
except ModuleNotFoundError:
try:
import google.colab
print(
"""
To enable running this notebook in Google Colab, install nightly
torch and torchaudio builds and the requisite third party libraries by
adding the following code block to the top of the notebook before running it:
!pip3 uninstall -y torch torchvision torchaudio
!pip3 install --pre torch torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
!pip3 install sentencepiece
!add-apt-repository -y ppa:savoury1/ffmpeg4
!apt-get -qq install -y ffmpeg
"""
)
except ModuleNotFoundError:
pass
raise
print(torch.__version__) print(torch.__version__)
print(torchaudio.__version__) print(torchaudio.__version__)
from torchaudio.prototype.io import Streamer
###################################################################### ######################################################################
# 3. Construct the pipeline # 3. Construct the pipeline
......
...@@ -29,13 +29,6 @@ libavfilter provides. ...@@ -29,13 +29,6 @@ libavfilter provides.
# ``conda install -c anaconda ffmpeg`` will install # ``conda install -c anaconda ffmpeg`` will install
# the required libraries. # the required libraries.
# #
# When running this tutorial in Google Colab, the following
# command should do.
#
# .. code::
#
# !add-apt-repository -y ppa:savoury1/ffmpeg4
# !apt-get -qq install -y ffmpeg
###################################################################### ######################################################################
# 1. Overview # 1. Overview
...@@ -77,7 +70,28 @@ import IPython ...@@ -77,7 +70,28 @@ import IPython
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import torch import torch
import torchaudio import torchaudio
from torchaudio.prototype.io import Streamer
try:
from torchaudio.prototype.io import Streamer
except ModuleNotFoundError:
try:
import google.colab
print(
"""
To enable running this notebook in Google Colab, install nightly
torch and torchaudio builds and the requisite third party libraries by
adding the following code block to the top of the notebook before running it:
!pip3 uninstall -y torch torchvision torchaudio
!pip3 install --pre torch torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
!add-apt-repository -y ppa:savoury1/ffmpeg4
!apt-get -qq install -y ffmpeg
"""
)
except ModuleNotFoundError:
pass
raise
print(torch.__version__) print(torch.__version__)
print(torchaudio.__version__) print(torchaudio.__version__)
......
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