naming and clarity improvements
@@ -129,15 +129,15 @@ class HFTransformersTranscription(BaseTranscription):
# Add times to ids
duration_sec = input_values.shape[1] / sample_rate
time_from_index = lambda index: index / len(predicted_ids) * duration_sec
- ids_with_time = map(lambda index, id: (time_from_index(index), id),
+ ids_with_time = map((lambda index, token_id: (time_from_index(index), token_id)),
enumerate(predicted_ids))
# remove entries which are just "padding" (i.e. no characers are recognized)
- is_padding = lambda id: id == processor.tokenizer.pad_token_id
- ids_with_time = filter(lambda _, id: not is_padding(id), ids_with_time)
+ is_padding = lambda token_id: token_id == processor.tokenizer.pad_token_id
+ ids_with_time = filter((lambda _, token_id: not is_padding(token_id)), ids_with_time)
# now split the ids into groups of ids where each group represents a word
- is_delimiter = lambda id: id == processor.tokenizer.word_delimiter_token_id
+ is_delimiter = lambda token_id: token_id == processor.tokenizer.word_delimiter_token_id
word_groups = groupby(
ids_with_time, lambda x: is_delimiter(x[1]))
