From 48b2dddcd9704a674dffc78c273b25334bddfd12 Mon Sep 17 00:00:00 2001 From: dohe0342 Date: Sat, 25 Feb 2023 15:20:21 +0900 Subject: [PATCH] from local --- .../ASR/conformer_ctc2/.decode.py.swp | Bin 57344 -> 61440 bytes egs/librispeech/ASR/conformer_ctc2/decode.py | 23 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/egs/librispeech/ASR/conformer_ctc2/.decode.py.swp b/egs/librispeech/ASR/conformer_ctc2/.decode.py.swp index 0cffc404f8938a5ee7ac692a08fe04d62a85ead8..d9393c9317e9b75f5cdd338bbaa20077795146fc 100644 GIT binary patch delta 872 zcmX}qUr1A77{~GFY-gL=*3K+en8JaAE@IPKH;KWByco2(HHsVsI)j233Kl`;j#LW$ z+0}`zDhFN|)r2}1fp{?y`$J2+2!i~B-6cp7bQ96m_b}*z&p9vWD1y%#7t?snz!52RIGjzRk1SKg#V?kMtujG zM0RXrg5?o2(6`sP<`+4KZnQx>wtgo*38jA2BfK=9os@(E9H3m1^aNuoDst%D~_=33*mr3N&i!*3P80$(sLH&POtJ&5@Gnw0CrE)QcmC5N2D?fN+$ml;W z66c!*`m(c))mKW5B&+y_4|s)#xQPUgq77dBA<-4gVh9=ZB7j8_yoxY1ydkI&oWLY->TFbbDQS?B?8fm@9b3Dc<29ZEFYNS`jUF1Do l{6Y*iN$V@#p@b>i#w8>WLIXTl=cLw9a9N6)Ryo<>rho0Egh~Ja delta 654 zcmaLUPe_w-9LMp`Hl3}uwnCOj#6w+HPTQ>njiQsr79l7h;y)fiaNC1D#sXstF9|`& zMC8-SRfR5%q01J7vU@sz7@Cz$=ff5FB6B(p&38xXn@38b4Wjw+Ny2C1}o#FyQ zm^&uT;uZQ(i-n`oee@!ZrI7R#QD&qO=^8 zo}mLt)MK|=+Qc$GqKs)|5XJW@=@TY!87b7E5|IAjD?Xr%ade>*jYz`#gZG#|%QJ}) zWN{ry{N AttributeDict: return params +def greedy_search( + ctc_probs: torch.Tensor, + mask: torch.Tensor, +) -> List[List[int]]: + """Apply CTC greedy search + Args: + ctc_probs (torch.Tensor): (batch, max_len, num_bpe) + mask (torch.Tensor): (batch, max_len) + Returns: + best path result + """ + + _, max_index = ctc_probs.max(2) # (B, maxlen) + max_index = max_index.masked_fill_(mask, 0) # (B, maxlen) + + ret_hyps = [] + for hyp in max_index: + hyp = torch.unique_consecutive(hyp) + hyp = hyp[hyp > 0].tolist() + ret_hyps.append(hyp) + return ret_hyps + + def ctc_greedy_search( ctc_probs: torch.Tensor, mask: torch.Tensor,