@@ -252,15 +252,15 @@ def init_decoder(self, batch_size, vocab_list, decoding_method,
252
252
init ctc decoders
253
253
Args:
254
254
batch_size(int): Batch size for input data
255
- vocab_list (list): [ List of tokens in the vocabulary, for decoding.]
256
- decoding_method (str): [" ctc_beam_search"]
257
- lang_model_path (str): [ language model path]
258
- beam_alpha (float): [ beam_alpha]
259
- beam_beta (float): [ beam_beta]
260
- beam_size (int): [ beam_size]
261
- cutoff_prob (float): [ cutoff probability in beam search]
262
- cutoff_top_n (int): [ cutoff_top_n]
263
- num_processes (int): [ num_processes]
255
+ vocab_list (list): List of tokens in the vocabulary, for decoding
256
+ decoding_method (str): ctc_beam_search
257
+ lang_model_path (str): language model path
258
+ beam_alpha (float): beam_alpha
259
+ beam_beta (float): beam_beta
260
+ beam_size (int): beam_size
261
+ cutoff_prob (float): cutoff probability in beam search
262
+ cutoff_top_n (int): cutoff_top_n
263
+ num_processes (int): num_processes
264
264
265
265
Raises:
266
266
ValueError: when decoding_method not support.
@@ -299,15 +299,15 @@ def decode_probs_offline(self, probs, logits_lens, vocab_list,
299
299
Args:
300
300
probs (Tensor): activation after softmax
301
301
logits_lens (Tensor): audio output lens
302
- vocab_list (list): [ List of tokens in the vocabulary, for decoding.]
303
- decoding_method (str): [" ctc_beam_search"]
304
- lang_model_path (str): [ language model path]
305
- beam_alpha (float): [ beam_alpha]
306
- beam_beta (float): [ beam_beta]
307
- beam_size (int): [ beam_size]
308
- cutoff_prob (float): [ cutoff probability in beam search]
309
- cutoff_top_n (int): [ cutoff_top_n]
310
- num_processes (int): [ num_processes]
302
+ vocab_list (list): List of tokens in the vocabulary, for decoding
303
+ decoding_method (str): ctc_beam_search
304
+ lang_model_path (str): language model path
305
+ beam_alpha (float): beam_alpha
306
+ beam_beta (float): beam_beta
307
+ beam_size (int): beam_size
308
+ cutoff_prob (float): cutoff probability in beam search
309
+ cutoff_top_n (int): cutoff_top_n
310
+ num_processes (int): num_processes
311
311
312
312
Raises:
313
313
ValueError: when decoding_method not support.
@@ -340,14 +340,14 @@ def get_decoder(self, vocab_list, batch_size, beam_alpha, beam_beta,
340
340
"""
341
341
init get ctc decoder
342
342
Args:
343
- vocab_list (list): [ List of tokens in the vocabulary, for decoding.]
343
+ vocab_list (list): List of tokens in the vocabulary, for decoding.
344
344
batch_size(int): Batch size for input data
345
- beam_alpha (float): [ beam_alpha]
346
- beam_beta (float): [ beam_beta]
347
- beam_size (int): [ beam_size]
348
- num_processes (int): [ num_processes]
349
- cutoff_prob (float): [ cutoff probability in beam search]
350
- cutoff_top_n (int): [ cutoff_top_n]
345
+ beam_alpha (float): beam_alpha
346
+ beam_beta (float): beam_beta
347
+ beam_size (int): beam_size
348
+ num_processes (int): num_processes
349
+ cutoff_prob (float): cutoff probability in beam search
350
+ cutoff_top_n (int): cutoff_top_n
351
351
352
352
Raises:
353
353
ValueError: when decoding_method not support.
@@ -370,8 +370,8 @@ def next(self, probs, logits_lens):
370
370
"""
371
371
Input probs into ctc decoder
372
372
Args:
373
- probs (list(list(float))): [ probs for a batch of data]
374
- logits_lens (list(int)): [ logits lens for a batch of data]
373
+ probs (list(list(float))): probs for a batch of data
374
+ logits_lens (list(int)): logits lens for a batch of data
375
375
Raises:
376
376
Exception: when the ctc decoder is not initialized
377
377
ValueError: when decoding_method not support.
@@ -405,8 +405,8 @@ def decode(self):
405
405
Exception: when the ctc decoder is not initialized
406
406
ValueError: when decoding_method not support.
407
407
Returns:
408
- results_best (list(str)): [ The best result for a batch of data]
409
- results_beam (list(list(str))): [ The beam search result for a batch of data]
408
+ results_best (list(str)): The best result for a batch of data
409
+ results_beam (list(list(str))): The beam search result for a batch of data
410
410
"""
411
411
if self .beam_search_decoder is None :
412
412
raise Exception (
@@ -426,7 +426,12 @@ def decode(self):
426
426
427
427
return results_best , results_beam
428
428
429
- def reset_decoder (self , batch_size = - 1 , beam_size = - 1 , num_processes = - 1 , cutoff_prob = - 1.0 , cutoff_top_n = - 1 ):
429
+ def reset_decoder (self ,
430
+ batch_size = - 1 ,
431
+ beam_size = - 1 ,
432
+ num_processes = - 1 ,
433
+ cutoff_prob = - 1.0 ,
434
+ cutoff_top_n = - 1 ):
430
435
if batch_size > 0 :
431
436
self .batch_size = batch_size
432
437
if beam_size > 0 :
@@ -445,7 +450,9 @@ def reset_decoder(self, batch_size=-1, beam_size=-1, num_processes=-1, cutoff_pr
445
450
if self .beam_search_decoder is None :
446
451
raise Exception (
447
452
"You need to initialize the beam_search_decoder firstly" )
448
- self .beam_search_decoder .reset_state (self .batch_size , self .beam_size , self .num_processes , self .cutoff_prob , self .cutoff_top_n )
453
+ self .beam_search_decoder .reset_state (
454
+ self .batch_size , self .beam_size , self .num_processes ,
455
+ self .cutoff_prob , self .cutoff_top_n )
449
456
450
457
def del_decoder (self ):
451
458
"""
0 commit comments