File size: 3,429 Bytes
12da6cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qjubHCEzYtG8"
      },
      "source": [
        "### Step 1. Download InfoRE dataset"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "zCBJzJi6BE_o"
      },
      "outputs": [],
      "source": [
        "%%capture\n",
        "%%bash\n",
        "mkdir -p /content/data\n",
        "cd /content/data\n",
        "wget https://huggingface.co/datasets/ntt123/infore/resolve/main/infore_16k.zip\n",
        "# unzip -P BroughtToYouByInfoRe 25hours.zip\n",
        "unzip infore_16k.zip"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "6C47hb9nYzmB"
      },
      "source": [
        "### Step 2. Normalize audio clip"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Hp9TK8PbBcQM"
      },
      "outputs": [],
      "source": [
        "%%capture\n",
        "!sudo apt install -y sox\n",
        "!pip install soundfile librosa\n",
        "!pip install onnxruntime==1.11.1"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "FW45D8xM9Mcc",
        "outputId": "8d7ea7a9-ea5a-48ca-88fe-37dd4ed55d9b"
      },
      "outputs": [],
      "source": [
        "!mkdir -p /content/infore_16k\n",
        "from pathlib import Path\n",
        "import os\n",
        "from tqdm.cli import tqdm\n",
        "\n",
        "wavs = sorted(Path(\"/content/data/InfoRe\").glob(\"*.wav\"))\n",
        "for path in tqdm(wavs):\n",
        "    out = Path(\"/content/infore_16k\") / path.name\n",
        "    cmd = f\"sox {path} -c 1 -e signed-integer -b 16 -r 16k --norm=-3 {out}\"\n",
        "    os.system(cmd)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kooiBrsQY5sQ"
      },
      "source": [
        "### Step 3. Denoise using DNS-Challenge's baseline"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "hsXeNkZ3Xacj"
      },
      "outputs": [],
      "source": [
        "!git clone https://github.com/microsoft/DNS-Challenge\n",
        "%cd DNS-Challenge/NSNet2-baseline/\n",
        "!git checkout -f 8b87a33b2892f147b5c7ad39ea978453730db269\n",
        "!python run_nsnet2.py -i /content/infore_16k/ -o /content/infore_16k_denoised -m ./nsnet2-20ms-baseline.onnx"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "T5JtZwKgZI4r"
      },
      "source": [
        "### Step 4. Zip the denoised dataset"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "eeFggV0uYop_"
      },
      "outputs": [],
      "source": [
        "%cd /content\n",
        "!cp /content/data/InfoRe/*.txt ./infore_16k_denoised\n",
        "!cd ./infore_16k_denoised; zip -r ../infore_16k_denoised.zip ."
      ]
    }
  ],
  "metadata": {
    "colab": {
      "collapsed_sections": [],
      "name": "prepare_infore_dataset.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}