{"action":"created","comment":{"url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments/60503839","id":60503839,"diff_hunk":"@@ -0,0 +1,299 @@\n+#!/usr/bin/env python\n+# Copyright 2016  Tom Ko\n+# Apache 2.0\n+# script to generate reverberated data\n+\n+# we're using python 3.x style print but want it to work in python 2.x,\n+from __future__ import print_function\n+import argparse, glob, math, os, random, sys, warnings, copy, imp, ast\n+\n+train_lib = imp.load_source('ntl', 'steps/nnet3/nnet3_train_lib.py')\n+\n+class list_cyclic_iterator:\n+  def __init__(self, list, random_seed = 0):\n+    self.list_index = 0\n+    self.list = list\n+    random.seed(random_seed)\n+    random.shuffle(self.list)\n+\n+  def next(self):\n+    item = self.list[self.list_index]\n+    self.list_index = (self.list_index + 1) % len(self.list)\n+    return item\n+\n+\n+def GetArgs():\n+    # we add compulsary arguments as named arguments for readability\n+    parser = argparse.ArgumentParser(description=\"Generate corrupted data\"\n+                                                 \"for neural network training\",\n+                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n+\n+    parser.add_argument(\"--rir-list-file\", type=str, required = True, \n+                        help=\"RIR information file\")\n+    parser.add_argument(\"--noise-list-file\", type=str, default = None,\n+                        help=\"Noise information file\")\n+    parser.add_argument(\"--num-replications\", type=int, dest = \"num_replica\", default = 1,\n+                        help=\"Number of replicate to generated for the data\")\n+    parser.add_argument('--snrs', type=str, dest = \"snr_string\", default = '20:10:0', help='snrs to be used for corruption')\n+    parser.add_argument('--prefix', type=str, default = None, help='prefix for the id of the corrupted utterances')\n+    parser.add_argument(\"--speech-rvb-probability\", type=float, default = 0.8,\n+                        help=\"Probability of reverberating the speech signal, e.g. 0 <= p <= 1\")\n+    parser.add_argument(\"--noise-adding-probability\", type=float, default = 0.4,\n+                        help=\"Probability of adding point-source noises, e.g. 0 <= p <= 1\")\n+    parser.add_argument(\"--max-noises-added\", type=int, default = 2,\n+                        help=\"Maximum number of point-source noises could be added\")\n+    parser.add_argument(\"input_dir\",\n+                        help=\"Input data directory\")\n+    parser.add_argument(\"output_dir\",\n+                        help=\"Output data directory\")\n+\n+    print(' '.join(sys.argv))\n+\n+    args = parser.parse_args()\n+    args = CheckArgs(args)\n+\n+    return args\n+\n+def CheckArgs(args):\n+    if not os.path.exists(args.output_dir):\n+        os.makedirs(args.output_dir)\n+\n+    ## Check arguments.\n+    if args.rir_list_file is None:\n+        raise Exception(\"Rir information file must be provided\")\n+    \n+    if not os.path.isfile(args.rir_list_file):\n+        raise Exception(args.rir_list_file + \"not found\")\n+    \n+    if args.noise_list_file is not None:\n+        if not os.path.isfile(args.noise_list_file):\n+            raise Exception(args.noise_list_file + \"not found\")\n+\n+    if args.num_replica > 1 and args.prefix is None:\n+        args.prefix = \"rvb\"\n+        warnings.warn(\"--prefix is set to 'rvb' as --num-replications is larger than 1.\")\n+\n+    return args\n+\n+def ParseFileToDict(file, assert2fields = False, value_processor = None):\n+    if value_processor is None:\n+        value_processor = lambda x: x[0]\n+\n+    dict = {}\n+    for line in open(file, 'r'):\n+        parts = line.split()\n+        if assert2fields:\n+            assert(len(parts) == 2)\n+\n+        dict[parts[0]] = value_processor(parts[1:])\n+    return dict\n+\n+\n+# This is the major function to generate pipeline command for the corruption\n+# The rir list would have the following format:\n+# --rir-id <string,compulsary> --room-id <string,compulsary> --receiver-position-id <string,optional> --source-position-id <string,optional> --rt-60 < <float,optional> --drr <float, optional> < location(support Kaldi IO strings) >\n+# The noise list would have the following format:\n+# --noise-id <string,compulsary> --noise-type <choices = (isotropic, point source),compulsary> --bg-fg-type <choices=(background|foreground), default=background> --rir-file <str, compulsary if isotropic, should not be specified if point-source> < location=(support Kaldi IO strings) >\n+def CorruptWav(wav_scp, durations, output_dir, room_list, noise_list, snr_string, num_replica, prefix, speech_rvb_probability, noise_adding_probability, max_noises_added):","path":"egs/wsj/s5/steps/data/reverberate_data_dir.py","position":97,"original_position":97,"commit_id":"356fa8258d848e3b092c5b894f6a7b4cab63b29c","original_commit_id":"356fa8258d848e3b092c5b894f6a7b4cab63b29c","user":{"login":"vijayaditya","id":3895456,"avatar_url":"https://avatars.githubusercontent.com/u/3895456?v=3","gravatar_id":"","url":"https://api.github.com/users/vijayaditya","html_url":"https://github.com/vijayaditya","followers_url":"https://api.github.com/users/vijayaditya/followers","following_url":"https://api.github.com/users/vijayaditya/following{/other_user}","gists_url":"https://api.github.com/users/vijayaditya/gists{/gist_id}","starred_url":"https://api.github.com/users/vijayaditya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vijayaditya/subscriptions","organizations_url":"https://api.github.com/users/vijayaditya/orgs","repos_url":"https://api.github.com/users/vijayaditya/repos","events_url":"https://api.github.com/users/vijayaditya/events{/privacy}","received_events_url":"https://api.github.com/users/vijayaditya/received_events","type":"User","site_admin":false},"body":"process the snr_string before calling this function. Better provide SNRs as a float array.","created_at":"2016-04-20T23:14:05Z","updated_at":"2016-04-20T23:14:05Z","html_url":"https://github.com/kaldi-asr/kaldi/pull/706#discussion_r60503839","pull_request_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706","_links":{"self":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments/60503839"},"html":{"href":"https://github.com/kaldi-asr/kaldi/pull/706#discussion_r60503839"},"pull_request":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706"}}},"pull_request":{"url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706","id":66773151,"html_url":"https://github.com/kaldi-asr/kaldi/pull/706","diff_url":"https://github.com/kaldi-asr/kaldi/pull/706.diff","patch_url":"https://github.com/kaldi-asr/kaldi/pull/706.patch","issue_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/706","number":706,"state":"open","locked":false,"title":"A new steps/data/reverberate_data_dir.py script","user":{"login":"tomkocse","id":13828721,"avatar_url":"https://avatars.githubusercontent.com/u/13828721?v=3","gravatar_id":"","url":"https://api.github.com/users/tomkocse","html_url":"https://github.com/tomkocse","followers_url":"https://api.github.com/users/tomkocse/followers","following_url":"https://api.github.com/users/tomkocse/following{/other_user}","gists_url":"https://api.github.com/users/tomkocse/gists{/gist_id}","starred_url":"https://api.github.com/users/tomkocse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomkocse/subscriptions","organizations_url":"https://api.github.com/users/tomkocse/orgs","repos_url":"https://api.github.com/users/tomkocse/repos","events_url":"https://api.github.com/users/tomkocse/events{/privacy}","received_events_url":"https://api.github.com/users/tomkocse/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-17T16:31:02Z","updated_at":"2016-04-20T23:14:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"140084da786dcf44a011834a7c0ba682d09661a8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706/commits","review_comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706/comments","review_comment_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/706/comments","statuses_url":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/356fa8258d848e3b092c5b894f6a7b4cab63b29c","head":{"label":"tomkocse:new_rvb","ref":"new_rvb","sha":"356fa8258d848e3b092c5b894f6a7b4cab63b29c","user":{"login":"tomkocse","id":13828721,"avatar_url":"https://avatars.githubusercontent.com/u/13828721?v=3","gravatar_id":"","url":"https://api.github.com/users/tomkocse","html_url":"https://github.com/tomkocse","followers_url":"https://api.github.com/users/tomkocse/followers","following_url":"https://api.github.com/users/tomkocse/following{/other_user}","gists_url":"https://api.github.com/users/tomkocse/gists{/gist_id}","starred_url":"https://api.github.com/users/tomkocse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomkocse/subscriptions","organizations_url":"https://api.github.com/users/tomkocse/orgs","repos_url":"https://api.github.com/users/tomkocse/repos","events_url":"https://api.github.com/users/tomkocse/events{/privacy}","received_events_url":"https://api.github.com/users/tomkocse/received_events","type":"User","site_admin":false},"repo":{"id":40872652,"name":"kaldi","full_name":"tomkocse/kaldi","owner":{"login":"tomkocse","id":13828721,"avatar_url":"https://avatars.githubusercontent.com/u/13828721?v=3","gravatar_id":"","url":"https://api.github.com/users/tomkocse","html_url":"https://github.com/tomkocse","followers_url":"https://api.github.com/users/tomkocse/followers","following_url":"https://api.github.com/users/tomkocse/following{/other_user}","gists_url":"https://api.github.com/users/tomkocse/gists{/gist_id}","starred_url":"https://api.github.com/users/tomkocse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomkocse/subscriptions","organizations_url":"https://api.github.com/users/tomkocse/orgs","repos_url":"https://api.github.com/users/tomkocse/repos","events_url":"https://api.github.com/users/tomkocse/events{/privacy}","received_events_url":"https://api.github.com/users/tomkocse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tomkocse/kaldi","description":"This is now the official location of the Kaldi project.","fork":true,"url":"https://api.github.com/repos/tomkocse/kaldi","forks_url":"https://api.github.com/repos/tomkocse/kaldi/forks","keys_url":"https://api.github.com/repos/tomkocse/kaldi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomkocse/kaldi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomkocse/kaldi/teams","hooks_url":"https://api.github.com/repos/tomkocse/kaldi/hooks","issue_events_url":"https://api.github.com/repos/tomkocse/kaldi/issues/events{/number}","events_url":"https://api.github.com/repos/tomkocse/kaldi/events","assignees_url":"https://api.github.com/repos/tomkocse/kaldi/assignees{/user}","branches_url":"https://api.github.com/repos/tomkocse/kaldi/branches{/branch}","tags_url":"https://api.github.com/repos/tomkocse/kaldi/tags","blobs_url":"https://api.github.com/repos/tomkocse/kaldi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomkocse/kaldi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomkocse/kaldi/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomkocse/kaldi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomkocse/kaldi/statuses/{sha}","languages_url":"https://api.github.com/repos/tomkocse/kaldi/languages","stargazers_url":"https://api.github.com/repos/tomkocse/kaldi/stargazers","contributors_url":"https://api.github.com/repos/tomkocse/kaldi/contributors","subscribers_url":"https://api.github.com/repos/tomkocse/kaldi/subscribers","subscription_url":"https://api.github.com/repos/tomkocse/kaldi/subscription","commits_url":"https://api.github.com/repos/tomkocse/kaldi/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomkocse/kaldi/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomkocse/kaldi/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomkocse/kaldi/issues/comments{/number}","contents_url":"https://api.github.com/repos/tomkocse/kaldi/contents/{+path}","compare_url":"https://api.github.com/repos/tomkocse/kaldi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomkocse/kaldi/merges","archive_url":"https://api.github.com/repos/tomkocse/kaldi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomkocse/kaldi/downloads","issues_url":"https://api.github.com/repos/tomkocse/kaldi/issues{/number}","pulls_url":"https://api.github.com/repos/tomkocse/kaldi/pulls{/number}","milestones_url":"https://api.github.com/repos/tomkocse/kaldi/milestones{/number}","notifications_url":"https://api.github.com/repos/tomkocse/kaldi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomkocse/kaldi/labels{/name}","releases_url":"https://api.github.com/repos/tomkocse/kaldi/releases{/id}","deployments_url":"https://api.github.com/repos/tomkocse/kaldi/deployments","created_at":"2015-08-17T07:12:03Z","updated_at":"2015-08-17T07:12:13Z","pushed_at":"2016-04-18T15:30:23Z","git_url":"git://github.com/tomkocse/kaldi.git","ssh_url":"git@github.com:tomkocse/kaldi.git","clone_url":"https://github.com/tomkocse/kaldi.git","svn_url":"https://github.com/tomkocse/kaldi","homepage":"http://kaldi-asr.org","size":101321,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"kaldi-asr:master","ref":"master","sha":"d884b15c43ae6b88079250b0acf383a7c0b42cc0","user":{"login":"kaldi-asr","id":11650082,"avatar_url":"https://avatars.githubusercontent.com/u/11650082?v=3","gravatar_id":"","url":"https://api.github.com/users/kaldi-asr","html_url":"https://github.com/kaldi-asr","followers_url":"https://api.github.com/users/kaldi-asr/followers","following_url":"https://api.github.com/users/kaldi-asr/following{/other_user}","gists_url":"https://api.github.com/users/kaldi-asr/gists{/gist_id}","starred_url":"https://api.github.com/users/kaldi-asr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaldi-asr/subscriptions","organizations_url":"https://api.github.com/users/kaldi-asr/orgs","repos_url":"https://api.github.com/users/kaldi-asr/repos","events_url":"https://api.github.com/users/kaldi-asr/events{/privacy}","received_events_url":"https://api.github.com/users/kaldi-asr/received_events","type":"Organization","site_admin":false},"repo":{"id":34275045,"name":"kaldi","full_name":"kaldi-asr/kaldi","owner":{"login":"kaldi-asr","id":11650082,"avatar_url":"https://avatars.githubusercontent.com/u/11650082?v=3","gravatar_id":"","url":"https://api.github.com/users/kaldi-asr","html_url":"https://github.com/kaldi-asr","followers_url":"https://api.github.com/users/kaldi-asr/followers","following_url":"https://api.github.com/users/kaldi-asr/following{/other_user}","gists_url":"https://api.github.com/users/kaldi-asr/gists{/gist_id}","starred_url":"https://api.github.com/users/kaldi-asr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaldi-asr/subscriptions","organizations_url":"https://api.github.com/users/kaldi-asr/orgs","repos_url":"https://api.github.com/users/kaldi-asr/repos","events_url":"https://api.github.com/users/kaldi-asr/events{/privacy}","received_events_url":"https://api.github.com/users/kaldi-asr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kaldi-asr/kaldi","description":"This is now the official location of the Kaldi project.","fork":false,"url":"https://api.github.com/repos/kaldi-asr/kaldi","forks_url":"https://api.github.com/repos/kaldi-asr/kaldi/forks","keys_url":"https://api.github.com/repos/kaldi-asr/kaldi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaldi-asr/kaldi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaldi-asr/kaldi/teams","hooks_url":"https://api.github.com/repos/kaldi-asr/kaldi/hooks","issue_events_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/events{/number}","events_url":"https://api.github.com/repos/kaldi-asr/kaldi/events","assignees_url":"https://api.github.com/repos/kaldi-asr/kaldi/assignees{/user}","branches_url":"https://api.github.com/repos/kaldi-asr/kaldi/branches{/branch}","tags_url":"https://api.github.com/repos/kaldi-asr/kaldi/tags","blobs_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/{sha}","languages_url":"https://api.github.com/repos/kaldi-asr/kaldi/languages","stargazers_url":"https://api.github.com/repos/kaldi-asr/kaldi/stargazers","contributors_url":"https://api.github.com/repos/kaldi-asr/kaldi/contributors","subscribers_url":"https://api.github.com/repos/kaldi-asr/kaldi/subscribers","subscription_url":"https://api.github.com/repos/kaldi-asr/kaldi/subscription","commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaldi-asr/kaldi/contents/{+path}","compare_url":"https://api.github.com/repos/kaldi-asr/kaldi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaldi-asr/kaldi/merges","archive_url":"https://api.github.com/repos/kaldi-asr/kaldi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaldi-asr/kaldi/downloads","issues_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues{/number}","pulls_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls{/number}","milestones_url":"https://api.github.com/repos/kaldi-asr/kaldi/milestones{/number}","notifications_url":"https://api.github.com/repos/kaldi-asr/kaldi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaldi-asr/kaldi/labels{/name}","releases_url":"https://api.github.com/repos/kaldi-asr/kaldi/releases{/id}","deployments_url":"https://api.github.com/repos/kaldi-asr/kaldi/deployments","created_at":"2015-04-20T17:23:16Z","updated_at":"2016-04-20T21:43:23Z","pushed_at":"2016-04-20T22:16:33Z","git_url":"git://github.com/kaldi-asr/kaldi.git","ssh_url":"git@github.com:kaldi-asr/kaldi.git","clone_url":"https://github.com/kaldi-asr/kaldi.git","svn_url":"https://github.com/kaldi-asr/kaldi","homepage":"http://kaldi-asr.org","size":115900,"stargazers_count":575,"watchers_count":575,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":349,"mirror_url":null,"open_issues_count":54,"forks":349,"open_issues":54,"watchers":575,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706"},"html":{"href":"https://github.com/kaldi-asr/kaldi/pull/706"},"issue":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/issues/706"},"comments":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/issues/706/comments"},"review_comments":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706/comments"},"review_comment":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/706/commits"},"statuses":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/356fa8258d848e3b092c5b894f6a7b4cab63b29c"}}}}