-
Notifications
You must be signed in to change notification settings - Fork 414
[not_for_merge_yet] fixing github workflows with automatic tests #2061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a162b11
cce2916
c0efe90
37666ca
86eb147
f7132de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| /exp/ahussein/tmp/icefall/egs/iwslt22_ta/ST/local/prepare_transcripts.py | ||
| ../../ST/local/prepare_transcripts.py |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,66 @@ | ||
| # Copyright 2023 Johns Hopkins University (Amir Hussein) | ||
| #!/usr/bin/python | ||
| """ | ||
| This script prepares transcript_words.txt from cutset | ||
| """ | ||
| from lhotse import CutSet | ||
| import argparse | ||
| import logging | ||
| import pdb | ||
| from pathlib import Path | ||
| import os | ||
| def get_parser(): | ||
| parser = argparse.ArgumentParser( | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter | ||
| ) | ||
| parser.add_argument( | ||
| "--cut", | ||
| type=str, | ||
| default="", | ||
| help="Cutset file", | ||
| ) | ||
| parser.add_argument( | ||
| "--src-langdir", | ||
| type=str, | ||
| default="", | ||
| help="name of the source lang-dir", | ||
| ) | ||
| parser.add_argument( | ||
| "--tgt-langdir", | ||
| type=str, | ||
| default=None, | ||
| help="name of the target lang-dir", | ||
| ) | ||
| return parser | ||
| def main(): | ||
| parser = get_parser() | ||
| args = parser.parse_args() | ||
| logging.info("Reading the cuts") | ||
| cuts = CutSet.from_file(args.cut) | ||
| if args.tgt_langdir != None: | ||
| logging.info("Target dir is not None") | ||
| langdirs = [Path(args.src_langdir), Path(args.tgt_langdir)] | ||
| else: | ||
| langdirs = [Path(args.src_langdir)] | ||
| for langdir in langdirs: | ||
| if not os.path.exists(langdir): | ||
| os.makedirs(langdir) | ||
| with open(langdirs[0] / "transcript_words.txt", 'w') as src, open(langdirs[1] / "transcript_words.txt", 'w') as tgt: | ||
| for c in cuts: | ||
| src_txt = c.supervisions[0].text | ||
| tgt_txt = c.supervisions[0].custom['translated_text']['eng'] | ||
| src.write(src_txt + '\n') | ||
| tgt.write(tgt_txt + '\n') | ||
| if __name__ == "__main__": | ||
| main() | ||
| # Copyright 2023 Johns Hopkins University (Amir Hussein) | ||
|
|
||
| #!/usr/bin/python | ||
| """ | ||
| This script prepares transcript_words.txt from cutset | ||
| """ | ||
|
|
||
| from lhotse import CutSet | ||
| import argparse | ||
| import logging | ||
| import pdb | ||
| from pathlib import Path | ||
| import os | ||
|
|
||
|
|
||
| def get_parser(): | ||
| parser = argparse.ArgumentParser( | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter | ||
| ) | ||
| parser.add_argument( | ||
| "--cut", | ||
| type=str, | ||
| default="", | ||
| help="Cutset file", | ||
| ) | ||
| parser.add_argument( | ||
| "--src-langdir", | ||
| type=str, | ||
| default="", | ||
| help="name of the source lang-dir", | ||
| ) | ||
| parser.add_argument( | ||
| "--tgt-langdir", | ||
| type=str, | ||
| default=None, | ||
| help="name of the target lang-dir", | ||
| ) | ||
| return parser | ||
|
|
||
|
|
||
| def main(): | ||
|
|
||
| parser = get_parser() | ||
| args = parser.parse_args() | ||
|
|
||
| logging.info("Reading the cuts") | ||
| cuts = CutSet.from_file(args.cut) | ||
| if args.tgt_langdir != None: | ||
| logging.info("Target dir is not None") | ||
| langdirs = [Path(args.src_langdir), Path(args.tgt_langdir)] | ||
| else: | ||
| langdirs = [Path(args.src_langdir)] | ||
|
|
||
| for langdir in langdirs: | ||
| if not os.path.exists(langdir): | ||
| os.makedirs(langdir) | ||
|
|
||
| with open(langdirs[0] / "transcript_words.txt", 'w') as src, open(langdirs[1] / "transcript_words.txt", 'w') as tgt: | ||
| for c in cuts: | ||
| src_txt = c.supervisions[0].text | ||
| tgt_txt = c.supervisions[0].custom['translated_text']['eng'] | ||
| src.write(src_txt + '\n') | ||
| tgt.write(tgt_txt + '\n') | ||
|
Comment on lines
+51
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IndexError when When Proposed fix: handle single langdir case- with open(langdirs[0] / "transcript_words.txt", 'w') as src, open(langdirs[1] / "transcript_words.txt", 'w') as tgt:
- for c in cuts:
- src_txt = c.supervisions[0].text
- tgt_txt = c.supervisions[0].custom['translated_text']['eng']
- src.write(src_txt + '\n')
- tgt.write(tgt_txt + '\n')
+ if args.tgt_langdir is not None:
+ with open(langdirs[0] / "transcript_words.txt", 'w') as src, \
+ open(langdirs[1] / "transcript_words.txt", 'w') as tgt:
+ for c in cuts:
+ src_txt = c.supervisions[0].text
+ tgt_txt = c.supervisions[0].custom['translated_text']['eng']
+ src.write(src_txt + '\n')
+ tgt.write(tgt_txt + '\n')
+ else:
+ with open(langdirs[0] / "transcript_words.txt", 'w') as src:
+ for c in cuts:
+ src_txt = c.supervisions[0].text
+ src.write(src_txt + '\n')🤖 Prompt for AI Agents |
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -1033,7 +1033,7 @@ def modified_beam_search( | |||
| nb_shift = logp_b - logits[..., 0] | ||||
| nb_shift = nb_shift.unsqueeze(-1) | ||||
| log_probs1 = (logits[..., 1:] / temperature).log_softmax(dim=-1) + nb_shift # (num_hyps, vocab_size-1) | ||||
| log_probs = torch.cat((logp_b.unsqueeze(-1), log_probs1), dim=-1) | ||||
| log_probs = torch.cat((logp_b.unsqueeze(-1), log_probs1), dim=-1) | ||||
| log_probs.add_(ys_log_probs) | ||||
| else: | ||||
| log_probs = (logits / temperature).log_softmax(dim=-1) # (num_hyps, vocab_size) | ||||
|
|
@@ -1203,17 +1203,17 @@ def modified_beam_search_hat( | |||
|
|
||||
| logits = logits.squeeze(1).squeeze(1) # (num_hyps, vocab_size) | ||||
|
|
||||
|
|
||||
| # For blank symbol, log-prob is log-sigmoid of the score | ||||
| logp_b = torch.nn.functional.logsigmoid(logits[..., 0]) | ||||
| # Additionally, to ensure the the probs of blank and non-blank sum to 1, we | ||||
| # need to add the following term to the log-probs of non-blank symbols. This | ||||
| # is equivalent to log(1 - sigmoid(logits[..., 0])). | ||||
| breakpoint() | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug This 🐛 Proposed fix- breakpoint()📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.13)1212-1212: Trace found: (T100) 🤖 Prompt for AI Agents |
||||
| nb_shift = logp_b - logits[..., 0] | ||||
|
|
||||
| nb_shift = nb_shift.unsqueeze(-1) | ||||
| log_probs1 = (logits[..., 1:] / temperature).log_softmax(dim=-1) + nb_shift # (num_hyps, vocab_size-1) | ||||
| log_probs = torch.cat((logp_b, log_probs), dim=-1) | ||||
| log_probs = torch.cat((logp_b.unsqueeze(-1), log_probs1), dim=-1) | ||||
| log_probs.add_(ys_log_probs) | ||||
|
|
||||
| vocab_size = log_probs.size(-1) | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../../librispeech/ASR/zipformer/profile.py | ||
| ../../ASR/zipformer/profile.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shebang should be at the beginning of the file.
The shebang (
#!/usr/bin/python) on line 3 should come before the copyright comment on line 1 to be recognized by the shell.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.14.13)
3-3: Shebang should be at the beginning of the file
(EXE005)
🤖 Prompt for AI Agents