Skip to content

Commit 285ff0d

Browse files
committed
add test
1 parent a403624 commit 285ff0d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/torchaudio_unittest/models/decoder/ctc_decoder_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,18 @@ def test_index_to_tokens(self, tokens):
169169

170170
expected_tokens = ["|", "f", "|", "o", "a"]
171171
self.assertEqual(tokens, expected_tokens)
172+
173+
def test_lm_lifecycle(self):
174+
"""Passing lm without assiging it to a vaiable won't cause runtime error
175+
176+
https://github.com/pytorch/audio/issues/3218
177+
"""
178+
from torchaudio.models.decoder import ctc_decoder
179+
from .ctc_decoder_utils import CustomZeroLM
180+
181+
decoder = ctc_decoder(
182+
lexicon=get_asset_path("decoder/lexicon.txt"),
183+
tokens=get_asset_path("decoder/tokens.txt"),
184+
lm=CustomZeroLM(),
185+
)
186+
decoder(torch.zeros((1, 3, NUM_TOKENS), dtype=torch.float32))

0 commit comments

Comments
 (0)