Repository: espnet/espnet
Issue: Old Docker Version failing recog_wav.sh due to a recent commit to support RNN-T decoding

The BeamSearchTransducer function in https://github.com/espnet/espnet/blob/master/espnet/asr/pytorch_backend/asr.py#L38

causes old docker versions to fail which do not have espnet-2 installed. 

@b-flo for the time being would it be okay to move this to - https://github.com/espnet/espnet/blob/master/espnet/asr/pytorch_backend/asr.py#L991

It seems like it's being used only for the RNN-T decoding.

Thanks
Sid

Changed files:
espnet/nets/transducer_decoder_interface.py, espnet/nets/beam_search_transducer.py

diff --git a/espnet/nets/beam_search_transducer.py b/espnet/nets/beam_search_transducer.py
index d0dcc9180..2ed74d02c 100644
--- a/espnet/nets/beam_search_transducer.py
+++ b/espnet/nets/beam_search_transducer.py
@@ -1,11 +1,6 @@
 """Search algorithms for transducer models."""
 
-from dataclasses import dataclass
-from typing import Any
-from typing import Dict
 from typing import List
-from typing import Optional
-from typing import Tuple
 from typing import Union
 
 import numpy as np
@@ -17,27 +12,9 @@ from espnet.nets.pytorch_backend.transducer.utils import is_prefix
 from espnet.nets.pytorch_backend.transducer.utils import recombine_hyps
 from espnet.nets.pytorch_backend.transducer.utils import select_lm_state
 from espnet.nets.pytorch_backend.transducer.utils import substract
-from espnet2.asr.decoder.abs_decoder import AbsDecoder
-
-
-@dataclass
-class Hypothesis:
-    """Default hypothesis definition for beam search."""
-
-    score: float
-    yseq: List[int]
-    dec_state: Union[
-        Tuple[torch.Tensor, Optional[torch.Tensor]], List[torch.Tensor], torch.Tensor
-    ]
-    lm_state: Union[Dict[str, Any], List[Any]] = None
-
-
-@dataclass
-class NSCHypothesis(Hypothesis):
-    """Extended hypothesis definition for NSC beam search."""
-
-    y: List[torch.Tensor] = None
-    lm_scores: torch.Tensor = None
+from espnet.nets.transducer_decoder_interface import Hypothesis
+from espnet.nets.transducer_decoder_interface import NSCHypothesis
+from espnet.nets.transducer_decoder_interface import TransducerDecoderInterface
 
 
 class BeamSearchTransducer:
@@ -45,7 +22,7 @@ class BeamSearchTransducer:
 
     def __init__(
         self,
-        decoder: Union[AbsDecoder, torch.nn.Module],
+        decoder: Union[TransducerDecoderInterface, torch.nn.Module],
         joint_network: torch.nn.Module,
         beam_size: int,
         lm: torch.nn.Module = None,
diff --git a/espnet/nets/transducer_decoder_interface.py b/espnet/nets/transducer_decoder_interface.py
index 3e7475cee..111771305 100644
--- a/espnet/nets/transducer_decoder_interface.py
+++ b/espnet/nets/transducer_decoder_interface.py
@@ -1,5 +1,6 @@
 """Transducer decoder interface module."""
 
+from dataclasses import dataclass
 from typing import Any
 from typing import Dict
 from typing import List
@@ -9,8 +10,25 @@ from typing import Union
 
 import torch
 
-from espnet.nets.beam_search_transducer import Hypothesis
-from espnet.nets.beam_search_transducer import NSCHypothesis
+
+@dataclass
+class Hypothesis:
+    """Default hypothesis definition for beam search."""
+
+    score: float
+    yseq: List[int]
+    dec_state: Union[
+        Tuple[torch.Tensor, Optional[torch.Tensor]], List[torch.Tensor], torch.Tensor
+    ]
+    lm_state: Union[Dict[str, Any], List[Any]] = None
+
+
+@dataclass
+class NSCHypothesis(Hypothesis):
+    """Extended hypothesis definition for NSC beam search."""
+
+    y: List[torch.Tensor] = None
+    lm_scores: torch.Tensor = None
 
 
 class TransducerDecoderInterface: