{"action":"created","comment":{"url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments/58812565","id":58812565,"diff_hunk":"@@ -0,0 +1,165 @@\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+nodes = imp.load_source('', 'steps/nnet3/components.py')\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+def return_nonempty_lines(lines):\n+  new_lines = []\n+  for line in lines:\n+    if len(line.strip()) > 0:\n+      new_lines.append(line.strip())\n+\n+  return new_lines\n+\n+\n+def GetArgs():\n+    # we add compulsary arguments as named arguments for readability\n+    parser = argparse.ArgumentParser(description=\"Writes config files and variables \"\n+                                                 \"for TDNNs creation and training\",\n+                                     epilog=\"See steps/nnet3/tdnn/train.sh for example.\")\n+\n+    parser.add_argument(\"--rir-list\", type=str, default = None,\n+                        help=\"RIR information file\")\n+    parser.add_argument(\"--noise-list\", 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(\"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 is None:\n+        raise Exception(\"Rir information file must be provided\")\n+    \n+    if not os.path.isfile(args.rir_list):\n+        raise Exception(args.rir_list + \"not found\")\n+    \n+    if args.noise_list is not None:\n+        if not os.path.isfile(args.noise_list):\n+            raise Exception(args.noise_list + \"not found\")\n+\n+    return args\n+\n+\n+def Corrupt_wav(input_dir, output_dir, rir_list, num_replica, prefix):\n+    rirs = list_cyclic_iterator(return_nonempty_lines(open(rir_list).readlines()), random_seed = 1)\n+    wav_files = open(input_dir + \"/wav.scp\", 'r').readlines()\n+    command_list = []\n+    for i in range(num_replica):\n+        for j in range(len(wav_files)):\n+            split1 = wav_files[j].split()\n+            wav_pipe = \" \".join(split1[1:])\n+            output_wav_id = prefix + str(i) + \"_\" + split1[0]\n+            rir = rirs.next().split()\n+            rir_file_location = rir[-1]\n+            command_list.append(\"{2} {0} wav-reverberate - {1} - |\\n\".format(wav_pipe, rir_file_location, output_wav_id))\n+\n+    file_handle = open(output_dir + \"/wav.scp\", 'w')\n+    file_handle.write(\"\".join(command_list))\n+    file_handle.close()\n+\n+\n+def Corrupt_wav_noise(input_dir, output_dir, rir_list, noise_list, snr_array, num_replica, prefix):\n+    rirs = list_cyclic_iterator(return_nonempty_lines(open(rir_list).readlines()), random_seed = 1)\n+    noises = list_cyclic_iterator(return_nonempty_lines(open(noise_list).readlines()), random_seed = 1)\n+    snrs = list_cyclic_iterator(snr_array)\n+    wav_files = open(input_dir + \"/wav.scp\", 'r').readlines()\n+    command_list = []\n+    for i in range(num_replica):\n+        for j in range(len(wav_files)):\n+            split1 = wav_files[j].split()\n+            wav_pipe = \" \".join(split1[1:])\n+            output_wav_id = prefix + str(i) + \"_\" + split1[0]\n+            rir = rirs.next().split()\n+            rir_file_location = rir[-1]\n+            noise = noises.next().split()\n+            noise_file_location = noise[-1]\n+            snr = snrs.next()\n+            command_list.append(\"{4} {0} wav-reverberate --noise-file={2} --snr-db={3} - {1} - |\\n\".format(wav_pipe, rir_file_location, noise_file_location, snr, output_wav_id))\n+\n+    file_handle = open(output_dir + \"/wav.scp\", 'w')\n+    file_handle.write(\"\".join(command_list))\n+    file_handle.close()\n+\n+\n+\n+def Replicate_file1(input_file, output_file, num_replica, prefix):\n+    list = map(lambda x: x.strip(), open(input_file))\n+    f = open(output_file, \"w\")\n+    for i in range(num_replica):\n+        for line in list:\n+            split1 = line.split()\n+            split1[0] = prefix + str(i) + \"_\" + split1[0]\n+            print(\" \".join(split1), file=f)\n+    f.close()\n+\n+\n+def Replicate_file2(input_file, output_file, num_replica, prefix):\n+    list = map(lambda x: x.strip(), open(input_file))\n+    f = open(output_file, \"w\")\n+    for i in range(num_replica):\n+        for line in list:\n+            split1 = line.split()\n+            split1[0] = prefix + str(i) + \"_\" + split1[0]\n+            split1[1] = prefix + str(i) + \"_\" + split1[1]\n+            print(\" \".join(split1), file=f)\n+    f.close()\n+\n+\n+def Main():\n+    args = GetArgs()\n+\n+    snr_array = [20 , 15, 10 , 5, 0]","path":"egs/swbd/s5c/local/reverberate/reverberate_data_dir.py","position":144,"original_position":144,"commit_id":"1683e258c9f571271668ab6e1d2b0898e7b7ed33","original_commit_id":"1683e258c9f571271668ab6e1d2b0898e7b7ed33","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":"snrs should be user specified.","created_at":"2016-04-07T02:46:44Z","updated_at":"2016-04-07T02:46:44Z","html_url":"https://github.com/kaldi-asr/kaldi/pull/667#discussion_r58812565","pull_request_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667","_links":{"self":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments/58812565"},"html":{"href":"https://github.com/kaldi-asr/kaldi/pull/667#discussion_r58812565"},"pull_request":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667"}}},"pull_request":{"url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667","id":65563712,"html_url":"https://github.com/kaldi-asr/kaldi/pull/667","diff_url":"https://github.com/kaldi-asr/kaldi/pull/667.diff","patch_url":"https://github.com/kaldi-asr/kaldi/pull/667.patch","issue_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/667","number":667,"state":"open","locked":false,"title":"[WIP] Simulated RIR reverberation in SWB","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-07T02:04:36Z","updated_at":"2016-04-07T02:46:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bb0d7cba376ddd584d79cead47bcaecf7ee0a2cc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667/commits","review_comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667/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/667/comments","statuses_url":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/1683e258c9f571271668ab6e1d2b0898e7b7ed33","head":{"label":"tomkocse:swb_rvb","ref":"swb_rvb","sha":"1683e258c9f571271668ab6e1d2b0898e7b7ed33","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-07T02:03:41Z","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":101243,"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:chain","ref":"chain","sha":"ce708ea1679467b915d50c5439eeb41a249e2d32","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-06T03:05:52Z","pushed_at":"2016-04-07T02:04:36Z","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":115488,"stargazers_count":542,"watchers_count":542,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":330,"mirror_url":null,"open_issues_count":50,"forks":330,"open_issues":50,"watchers":542,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667"},"html":{"href":"https://github.com/kaldi-asr/kaldi/pull/667"},"issue":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/issues/667"},"comments":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/issues/667/comments"},"review_comments":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/667/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/667/commits"},"statuses":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/1683e258c9f571271668ab6e1d2b0898e7b7ed33"}}}}