internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: espnet/espnet

Issue:
Freeze modules bug?
https://github.com/espnet/espnet/blob/25862dd93081746ac623720f31f4f0f323c9750e/espnet/tts/pytorch_backend/tts.py#L331-L334

Do you think to freeze the module of the model, the line should be change into:
 if any(mod.startswith(key) for key in args.freeze_mods): 
?




Discussion:

Resolving patch:
diff --git a/espnet/tts/pytorch_backend/tts.py b/espnet/tts/pytorch_backend/tts.py
--- a/espnet/tts/pytorch_backend/tts.py
+++ b/espnet/tts/pytorch_backend/tts.py
@@ -330,7 +330,8 @@ def train(args):
     # freeze modules, if specified
     if args.freeze_mods:
         for mod, param in model.state_dict().items():
-            if any(key.startswith(mod) for key in args.freeze_mods):
+            if any(mod.startswith(key) for key in args.freeze_mods):
+                logging.info(f"{mod} is frozen not to be updated.")
                 param.requires_grad = False
 
     # Setup an optimizer


Test patch:
Repository: espnet/espnet

Issue:
espnet2 inference error without language model
If not using a language model, the espnet2 asr_inference.py causes the following error. 

File "espnet2/espnet2/bin/asr_inference.py", line 152, in __init__
self.lm_train_args = lm_train_args
UnboundLocalError: local variable 'lm_train_args' referenced before assignment



Discussion:

Resolving patch:
diff --git a/espnet2/bin/asr_inference.py b/espnet2/bin/asr_inference.py
--- a/espnet2/bin/asr_inference.py
+++ b/espnet2/bin/asr_inference.py
@@ -147,7 +147,6 @@ def __init__(
 
         self.asr_model = asr_model
         self.asr_train_args = asr_train_args
-        self.lm_train_args = lm_train_args
         self.converter = converter
         self.tokenizer = tokenizer
         self.beam_search = beam_search


Test patch:
Repository: espnet/espnet

Issue:
Could not find a version that satisfies the requirement cupy-cuda102==6.0.0 
```
ERROR: Could not find a version that satisfies the requirement cupy-cuda102==6.0.0 (from versions: 7.2.0, 7.3.0, 7.4.0, 7.5.0, 7.6.0, 8.0.0a1, 8.0.0b1, 8.0.0b2, 8.0.0b3, 8.0.0b4)
``` 
cupy-cuda102 doesn't have version 6.0.0 , upgrade ```CHAINER_VERSION := 6.0.0``` to ```CHAINER_VERSION := 7.4.0```, please


Discussion:
 I see, thank you for the quick report. I'll update the makefile to care it, but ESPnet requires chainer=6.0.0, so the workaround is:

```sh
make PIP_CHAINER="chainer==6.0.0 cupy==6.0.0"   # Use not bundled cupy
make PIP_CHAINER="chainer==6.0.0"  # If you'll use pytorch backend only
make CHAINER_VERSION=""  # If you'll use espnet2 only
```

Resolving patch:
diff --git a/tools/check_install.py b/tools/check_install.py
--- a/tools/check_install.py
+++ b/tools/check_install.py
@@ -48,14 +48,22 @@ def main(args):
         default=False,
         help="Disable cuda-related tests",
     )
+    parser.add_argument(
+        "--no-cupy",
+        action="store_true",
+        default=False,
+        help="Disable cupy test",
+    )
     args = parser.parse_args(args)
 
     logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
     logging.info(f"python version = {sys.version}")
 
     library_list = []
+    if args.no_cuda:
+        args.no_cupy = True
 
-    if not args.no_cuda:
+    if not args.no_cupy:
         library_list.append(("cupy", ("6.0.0")))
 
     # check torch installation at first


Test patch:
Repository: espnet/espnet

Issue:
error in training stage "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Hello guys!
we are running the recipe of ljspeech of version 0.8.0 but on our data set, we are using google colaboratory. At the stage of training we are getting this error "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!". Any help ? 
log file is attached.
[train.log](https://github.com/espnet/espnet/files/5044468/train.log)

Thanks in advance
error in training stage "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Hello guys!
we are running the recipe of ljspeech of version 0.8.0 but on our data set, we are using google colaboratory. At the stage of training we are getting this error "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!". Any help ? 
log file is attached.
[train.log](https://github.com/espnet/espnet/files/5044468/train.log)

Thanks in advance


Discussion:
Hi.
It may be some tensor is on the CPU and some on the GPU. 
I guess you can fix this bug with `tensor = tensor.to(device=torch.device("cuda:0"))`

@kan-bayashi This error occurs if pytorch=1.6.
Sorry, I misss this issue.
I will check it.
Hi.
It may be some tensor is on the CPU and some on the GPU. 
I guess you can fix this bug with `tensor = tensor.to(device=torch.device("cuda:0"))`

@kan-bayashi This error occurs if pytorch=1.6.
Sorry, I misss this issue.
I will check it.

Resolving patch:
diff --git a/espnet/nets/pytorch_backend/e2e_tts_tacotron2.py b/espnet/nets/pytorch_backend/e2e_tts_tacotron2.py
--- a/espnet/nets/pytorch_backend/e2e_tts_tacotron2.py
+++ b/espnet/nets/pytorch_backend/e2e_tts_tacotron2.py
@@ -122,7 +122,7 @@ def _make_guided_attention_mask(ilen, olen, sigma):
 
         """
         grid_x, grid_y = torch.meshgrid(torch.arange(olen), torch.arange(ilen))
-        grid_x, grid_y = grid_x.float(), grid_y.float()
+        grid_x, grid_y = grid_x.float().to(olen.device), grid_y.float().to(ilen.device)
         return 1.0 - torch.exp(
             -((grid_y / ilen - grid_x / olen) ** 2) / (2 * (sigma ** 2))
         )


Test patch:
Repository: espnet/espnet

Issue:
How we can perform greedy decoding for RNN_T ?
Hi,
I trained an RNNT model using vivos recipe. I performed the decoding using beam search successfully now I'm trying to perform the decoding with greedy search I thought I could do that by setting beam-size parameter to 1:

**# decoding parameters**
batch: 0
**beam-size: 1**
search-type: default
score-norm: True

 but I got this error:

  File "/home/selma/espnet/espnet/asr/pytorch_backend/asr.py", line 1074, in recog
    js[name], nbest_hyps, train_args.char_list
  File "/home/selma/espnet/espnet/asr/asr_utils.py", line 828, in add_results_to_json
    rec_text, rec_token, rec_tokenid, score = parse_hypothesis(hyp, char_list)
  File "/home/selma/espnet/espnet/asr/asr_utils.py", line 796, in parse_hypothesis
    tokenid_as_list = list(map(int, hyp["yseq"][1:]))
TypeError: string indices must be integers

So I would like to know how could I perform greedy decoding for my model.
Thanks in advance!



Discussion:
I fixed this error by making these changes:

![image](https://user-images.githubusercontent.com/56079125/103017105-6ab05b00-4543-11eb-844f-73d93e3a9b66.png)

in https://github.com/espnet/espnet/blob/master/espnet/asr/asr_utils.py
But I don't know if this is the best way to do it or not.
@b-flo, could you check it?
I think the greedy decoding is important for the debugging purpose and we may include it as a test.

Resolving patch:
diff --git a/espnet/nets/beam_search_transducer.py b/espnet/nets/beam_search_transducer.py
--- a/espnet/nets/beam_search_transducer.py
+++ b/espnet/nets/beam_search_transducer.py
@@ -158,7 +158,7 @@ def greedy_search(self, h: torch.Tensor) -> List[Hypothesis]:
 
                 y, state, _ = self.decoder.score(hyp, cache, init_tensor)
 
-        return hyp
+        return [hyp]
 
     def default_beam_search(self, h: torch.Tensor) -> List[Hypothesis]:
         """Beam search implementation.
diff --git a/espnet/nets/e2e_asr_common.py b/espnet/nets/e2e_asr_common.py
--- a/espnet/nets/e2e_asr_common.py
+++ b/espnet/nets/e2e_asr_common.py
@@ -309,7 +309,7 @@ def __call__(self, hs_pad, ys_pad):
 
         for b in six.moves.range(batchsize):
             nbest_hyps = self.beam_search(hs_pad[b])
-            batch_nbest.append(nbest_hyps)
+            batch_nbest.append(nbest_hyps[-1])
 
         ys_hat = [nbest_hyp.yseq[1:] for nbest_hyp in batch_nbest]
 


Test patch:
diff --git a/test/test_e2e_asr_sa_transducer.py b/test/test_e2e_asr_sa_transducer.py
--- a/test/test_e2e_asr_sa_transducer.py
+++ b/test/test_e2e_asr_sa_transducer.py
@@ -280,10 +280,7 @@ def test_sa_transducer_trainable_and_decodable(train_dic, recog_dic):
         nbest = model.recognize(x[0, : ilens[0]].numpy(), beam_search)
 
         print(y[0])
-        if recog_args.beam_size == 1:
-            print(nbest["yseq"][1:-1])
-        else:
-            print(nbest[0]["yseq"][1:-1])
+        print(nbest[0]["yseq"][1:-1])
 
 
 def test_calculate_plot_attention():
Repository: espnet/espnet

Issue:
Typo: idim should be odim
https://github.com/espnet/espnet/blob/5160363973a1505b3987d6b37976bc04e1d4dad8/espnet/nets/pytorch_backend/transducer/blocks.py#L195

```bash
<<< out_dim = blocks_arch[-1]["idim"] 
>>> out_dim = blocks_arch[-1]["odim"]
``` 


Discussion:

Resolving patch:
diff --git a/espnet/nets/pytorch_backend/transducer/blocks.py b/espnet/nets/pytorch_backend/transducer/blocks.py
--- a/espnet/nets/pytorch_backend/transducer/blocks.py
+++ b/espnet/nets/pytorch_backend/transducer/blocks.py
@@ -192,7 +192,7 @@ def check_and_prepare(net_part, blocks_arch, input_layer):
         input_layer_odim = blocks_arch[0]["d_hidden"]
 
     if blocks_arch[-1]["type"] in ("tdnn", "causal-conv1d"):
-        out_dim = blocks_arch[-1]["idim"]
+        out_dim = blocks_arch[-1]["odim"]
     else:
         out_dim = blocks_arch[-1]["d_hidden"]
 


Test patch:
Repository: espnet/espnet

Issue:
Error with using compute-fbank-feats.py
Hello! I tried to use script compute-fbank-feats.py to compute fbank features from wav, and tried to use it according to its documentation https://espnet.github.io/espnet/apis/utils_py.html#compute-fbank-feats-py

as folllows:
```
python3.7 utils/compute-fbank-feats.py scp:wav.scp ark:out.ark
```

but got an error:

```
  File "utils/compute-fbank-feats.py", line 134, in <module>
    main()
  File "utils/compute-fbank-feats.py", line 128, in main
    fmax=args.fmax,
  File "/home/karina/.local/lib/python3.7/site-packages/espnet/transform/spectrogram.py", line 116, in logmelspectrogram
    x_stft, fs=fs, n_mels=n_mels, n_fft=n_fft, fmin=fmin, fmax=fmax, eps=eps
  File "/home/karina/.local/lib/python3.7/site-packages/espnet/transform/spectrogram.py", line 74, in stft2logmelspectrogram
    fmax = fs / 2 if fmax is None else fmax
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
```

wav.scp contains this text:
```
0 test.wav
```

Does anyone have ideas how to solve this error?


Discussion:

Resolving patch:
diff --git a/utils/compute-fbank-feats.py b/utils/compute-fbank-feats.py
--- a/utils/compute-fbank-feats.py
+++ b/utils/compute-fbank-feats.py
@@ -118,7 +118,7 @@ def main():
 
             lmspc = logmelspectrogram(
                 x=array,
-                fs=args.fs,
+                fs=args.fs if args.fs is not None else rate,
                 n_mels=args.n_mels,
                 n_fft=args.n_fft,
                 n_shift=args.n_shift,


Test patch:
Repository: espnet/espnet

Issue:
Question on chunk shift in ChunkIterFactory.build_iter()
In the code, shift width is calculated as a ratio of utterance length as follows:
S = int(L * self.chunk_shift_ratio)

Shouldn't shift width be calculated as a ratio of chunk length like below ?
S = int(W * self.chunk_shift_ratio)



Discussion:

Resolving patch:
diff --git a/espnet2/iterators/chunk_iter_factory.py b/espnet2/iterators/chunk_iter_factory.py
--- a/espnet2/iterators/chunk_iter_factory.py
+++ b/espnet2/iterators/chunk_iter_factory.py
@@ -145,7 +145,7 @@ def build_iter(
             cache_chunks = cache_chunks_dict.setdefault(W, {})
 
             # Shift width to the next chunk
-            S = int(L * self.chunk_shift_ratio)
+            S = int(W * self.chunk_shift_ratio)
             # Number of chunks
             N = (L - W) // S + 1
             if shuffle:


Test patch:
Repository: espnet/espnet

Issue:
Espnet2 ASR DataParallel API mismatching?
In `espnet/espnet2/train/trainer.py:250,17` 
It seems that `torch.nn.parallel.DataParallel` doesn't have a parameter `find_unused_parameters`.
Is it a bug?


Discussion:

Resolving patch:
diff --git a/espnet2/train/trainer.py b/espnet2/train/trainer.py
--- a/espnet2/train/trainer.py
+++ b/espnet2/train/trainer.py
@@ -247,7 +247,6 @@ def run(
             dp_model = torch.nn.parallel.DataParallel(
                 model,
                 device_ids=list(range(distributed_option.ngpu)),
-                find_unused_parameters=trainer_options.unused_parameters,
             )
         else:
             # NOTE(kamo): DataParallel also should work with ngpu=1,


Test patch:
Repository: espnet/espnet

Issue:
Error when "--field -5" is passed to espnet2.bin.tokenize_text
**Describe the bug**

```
D:\Anaconda\python.exe D:/repos/espnet/espnet2/bin/tokenize_text.py --token_type phn --input tmp.txt --output tmp.phn --field -2 --cleaner none --g2p g2p_en --add_symbol '$<blank>:0' --add_symbol '<oov>:1' --add_symbol '<sos/eos>:-1' --write_vocabulary false --keep_all_fields true
Traceback (most recent call last):
  File "D:/repos/espnet/espnet2/bin/tokenize_text.py", line 297, in <module>
    main()
  File "D:/repos/espnet/espnet2/bin/tokenize_text.py", line 293, in main
    tokenize(**kwargs)
  File "D:/repos/espnet/espnet2/bin/tokenize_text.py", line 112, in tokenize
    field = field2slice(field)
  File "D:/repos/espnet/espnet2/bin/tokenize_text.py", line 59, in field2slice
    slic = slice(s1 - 1, s2)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
```
This is because of a missing None check [here](https://github.com/espnet/espnet/blob/master/espnet2/bin/tokenize_text.py#L59)



Discussion:

Resolving patch:
diff --git a/espnet2/bin/tokenize_text.py b/espnet2/bin/tokenize_text.py
--- a/espnet2/bin/tokenize_text.py
+++ b/espnet2/bin/tokenize_text.py
@@ -28,7 +28,6 @@ def field2slice(field: Optional[str]) -> slice:
         slice(0, 3, None)
         >>> field2slice("-3")
         slice(None, 3, None)
-
     """
     field = field.strip()
     try:
@@ -54,9 +53,12 @@ def field2slice(field: Optional[str]) -> slice:
     except ValueError:
         raise RuntimeError(f"Format error: e.g. '2-', '2-5', or '-5': {field}")
 
-    # -1 because of 1-based integer following "cut" command
-    # e.g "1-3" -> slice(0, 3)
-    slic = slice(s1 - 1, s2)
+    if s1 is None:
+        slic = slice(None, s2)
+    else:
+        # -1 because of 1-based integer following "cut" command
+        # e.g "1-3" -> slice(0, 3)
+        slic = slice(s1 - 1, s2)
     return slic
 
 


Test patch:
Repository: espnet/espnet

Issue:
Speed alpha parameter in sythesize method for FastSpeech2 TTS
**Now:** 

the *speed_control_alpha* parameter is configurable in Text2Speech class constructor. https://github.com/espnet/espnet/blob/39032a3011ecaa7b4fc0bc60979e3933835d2aea/espnet2/bin/tts_inference.py#L63

---

**Problem**: 

I'm successfully serving FastSpeech2 model using the Text2Speech class. The model is loaded into GPU memory once and serving many incoming web requests. I need implement a possibility to slower or speed up a speech. The current implementation would require recreate Text2Speech with different *speed_control_alpha*.

---

**Suggestion**: 

Add *speed_control_alpha* into the synthesize method: https://github.com/espnet/espnet/blob/39032a3011ecaa7b4fc0bc60979e3933835d2aea/espnet2/bin/tts_inference.py#L127 
If not provided here it could use the default one from the constructor, otherwise use the provided one.

---

I could provide a pull-request if you see a suggestion useful.




Discussion:
That sounds like a reasonable option for me.
@kan-bayashi, what do you think?
Sorry for the late reply.
That seems reasonable, but be careful about the compatibility with the other models.

Resolving patch:
diff --git a/espnet2/bin/tts_inference.py b/espnet2/bin/tts_inference.py
--- a/espnet2/bin/tts_inference.py
+++ b/espnet2/bin/tts_inference.py
@@ -130,6 +130,7 @@ def __call__(
         speech: Union[torch.Tensor, np.ndarray] = None,
         durations: Union[torch.Tensor, np.ndarray] = None,
         spembs: Union[torch.Tensor, np.ndarray] = None,
+        speed_control_alpha: Optional[float] = None,
     ):
         assert check_argument_types()
 
@@ -147,10 +148,15 @@ def __call__(
         if spembs is not None:
             batch["spembs"] = spembs
 
+        cfg = self.decode_config
+        if speed_control_alpha is not None and isinstance(
+            self.tts, (FastSpeech, FastSpeech2)
+        ):
+            cfg = self.decode_config.copy()
+            cfg.update({"alpha": speed_control_alpha})
+
         batch = to_device(batch, self.device)
-        outs, outs_denorm, probs, att_ws = self.model.inference(
-            **batch, **self.decode_config
-        )
+        outs, outs_denorm, probs, att_ws = self.model.inference(**batch, **cfg)
 
         if att_ws is not None:
             duration, focus_rate = self.duration_calculator(att_ws)


Test patch:
Repository: espnet/espnet

Issue:
TTS lid=true bug
@kan-bayashi  Hi when I set use_lid=true , the following error occurs, like the support for lid is incomplete
`RuntimeError: The data-name must be one of ('text', 'speech', 'spembs', 'sids', 'durations', 'pitch', 'energy') for GANTTSTask: "lids" is not allowed.`


Discussion:
Thank you for your report! That is a bug. I will fix it.

Resolving patch:
diff --git a/espnet2/tasks/gan_tts.py b/espnet2/tasks/gan_tts.py
--- a/espnet2/tasks/gan_tts.py
+++ b/espnet2/tasks/gan_tts.py
@@ -221,7 +221,9 @@ def build_collate_fn(
     ]:
         assert check_argument_types()
         return CommonCollateFn(
-            float_pad_value=0.0, int_pad_value=0, not_sequence=["spembs", "sids"]
+            float_pad_value=0.0,
+            int_pad_value=0,
+            not_sequence=["spembs", "sids", "lids"],
         )
 
     @classmethod
@@ -260,10 +262,25 @@ def optional_data_names(
         cls, train: bool = True, inference: bool = False
     ) -> Tuple[str, ...]:
         if not inference:
-            retval = ("spembs", "sids", "durations", "pitch", "energy")
+            retval = (
+                "spembs",
+                "durations",
+                "pitch",
+                "energy",
+                "sids",
+                "lids",
+            )
         else:
             # Inference mode
-            retval = ("spembs", "sids", "speech", "durations", "pitch", "energy")
+            retval = (
+                "spembs",
+                "speech",
+                "durations",
+                "pitch",
+                "energy",
+                "sids",
+                "lids",
+            )
         return retval
 
     @classmethod
diff --git a/espnet2/tasks/tts.py b/espnet2/tasks/tts.py
--- a/espnet2/tasks/tts.py
+++ b/espnet2/tasks/tts.py
@@ -260,10 +260,25 @@ def optional_data_names(
         cls, train: bool = True, inference: bool = False
     ) -> Tuple[str, ...]:
         if not inference:
-            retval = ("spembs", "durations", "pitch", "energy", "sids", "lids")
+            retval = (
+                "spembs",
+                "durations",
+                "pitch",
+                "energy",
+                "sids",
+                "lids",
+            )
         else:
             # Inference mode
-            retval = ("spembs", "speech", "durations", "sids", "lids")
+            retval = (
+                "spembs",
+                "speech",
+                "durations",
+                "pitch",
+                "energy",
+                "sids",
+                "lids",
+            )
         return retval
 
     @classmethod


Test patch:
Repository: espnet/espnet

Issue:
Question on check_short_utt
I use `Conv2dSubsampling2` and have a tensor of size `[1, 5, 80]` that can not be processed by this subsampling module. If I pad it to `[1, 7, 80]`, then it works, but with `[1, 6, 80]` it does not, so I assume the minimum length is 7 frames for `Conv2dSubsampling2`. However, `check_short_utt` requires it to be at least 3 frames:
https://github.com/espnet/espnet/blob/afa8f8ec5b8ec77deb1a3c1531915ebbee7b80e6/espnet/nets/pytorch_backend/transformer/subsampling.py#L33-L34
Should it be changed to 7 or I get something wrong?


Discussion:
Thanks for your investigation. I think it should be a bug here. When I was adding this check, I checked the other cases but not this one. Since it has two 3-kernel without padding, 7 should be a valid number. Could you start a PR to fix the issue?
Thank you for the answer! Sure, will do.

Resolving patch:
diff --git a/espnet/nets/pytorch_backend/transformer/subsampling.py b/espnet/nets/pytorch_backend/transformer/subsampling.py
--- a/espnet/nets/pytorch_backend/transformer/subsampling.py
+++ b/espnet/nets/pytorch_backend/transformer/subsampling.py
@@ -30,8 +30,8 @@ def __init__(self, message, actual_size, limit):
 
 def check_short_utt(ins, size):
     """Check if the utterance is too short for subsampling."""
-    if isinstance(ins, Conv2dSubsampling2) and size < 3:
-        return True, 3
+    if isinstance(ins, Conv2dSubsampling2) and size < 7:
+        return True, 7
     if isinstance(ins, Conv2dSubsampling) and size < 7:
         return True, 7
     if isinstance(ins, Conv2dSubsampling6) and size < 11:


Test patch:
Repository: espnet/espnet

Issue:
AttributeError: 'NoneType' object has no attribute 'run'
I train conformer model using aishell recipe(ESPnet2) , but when in training stage , I got this:

2022-05-26 21:31:26,160 (trainer:328) INFO: 50epoch results: [train] iter_time=6.764e-05, forward_time=0.043, loss_ctc=0.331, loss_att=0.502, acc=0.993, loss=0.225, backward_time=0.040, optim_step_time=0.038, optim0_lr0=1.133e-04, train_time=0.264, time=51 minutes and 57 seconds, total_count=1181200, gpu_max_cached_mem_GB=5.084, [valid] loss_ctc=6.020, cer_ctc=0.112, loss_att=3.802, acc=0.916, cer=0.107, wer=0.466, loss=4.467, time=23.6 seconds, total_count=25950, gpu_max_cached_mem_GB=5.084, [att_plot] time=31.79 seconds, total_count=0, gpu_max_cached_mem_GB=5.084
2022-05-26 21:32:34,718 (trainer:374) INFO: There are no improvements in this epoch
2022-05-26 21:32:34,731 (trainer:449) INFO: The training was finished at 50 epochs 
2022-05-26 21:32:34,755 (average_nbest_models:70) INFO: Averaging 10best models: criterion="valid.acc": exp/asr_train_asr_conformer_raw_zh_char/valid.acc.ave_10best.pth
Traceback (most recent call last):
  File "/Share/lli/espnet/tools/anaconda/envs/espnet/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Share/lli/espnet/tools/anaconda/envs/espnet/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Share/lli/espnet/espnet2/bin/asr_train.py", line 23, in <module>
    main()
  File "/Share/lli/espnet/espnet2/bin/asr_train.py", line 19, in main
    ASRTask.main(cmd=cmd)
  File "/Share/lli/espnet/espnet2/tasks/abs_task.py", line 1011, in main
    cls.main_worker(args)
  File "/Share/lli/espnet/espnet2/tasks/abs_task.py", line 1318, in main_worker
    if wandb.run:
AttributeError: 'NoneType' object has no attribute 'run'
Accounting: time=170861 threads=1
Ended (code 1) at Thu May 26 21:35:06 CST 2022, elapsed time 170861 seconds

Basic environments:
OS information: Linux
python version: 3.7.4
espnet version: 202204
pytorch version 1.6.0
Task information:

Task: ASR
Recipe: aishell
ESPnet2
Could you please help me?


Discussion:
This is a bug. I'll fix it.

For workaround, please install wandb, but your training has been finished successfully. You can ignore it.

Resolving patch:
diff --git a/espnet2/tasks/abs_task.py b/espnet2/tasks/abs_task.py
--- a/espnet2/tasks/abs_task.py
+++ b/espnet2/tasks/abs_task.py
@@ -1315,7 +1315,7 @@ def main_worker(cls, args: argparse.Namespace):
                 distributed_option=distributed_option,
             )
 
-            if wandb.run:
+            if args.use_wandb and wandb.run:
                 wandb.finish()
 
     @classmethod


Test patch: