kurianbenoy commited on
Commit
ef173f1
1 Parent(s): ffada9a

Update nbs

Browse files
Files changed (2) hide show
  1. nbs/PytorchAudioInference.ipynb +18 -19
  2. requirements.txt +3 -2
nbs/PytorchAudioInference.ipynb CHANGED
@@ -87,9 +87,9 @@
87
  "metadata": {},
88
  "outputs": [],
89
  "source": [
90
- "base_folder = Path('../input/kaggle-pog-series-s01e02')\n",
91
  "\n",
92
- "items = get_files(base_folder, extensions='.ogg')"
93
  ]
94
  },
95
  {
@@ -110,7 +110,7 @@
110
  }
111
  ],
112
  "source": [
113
- "items\n"
114
  ]
115
  },
116
  {
@@ -126,24 +126,23 @@
126
  "\n",
127
  "def create_spectrogram(filename):\n",
128
  " audio, sr = torchaudio.load(filename)\n",
129
- " specgram = torchaudio.transforms.MelSpectrogram(sample_rate=sr, \n",
130
- " n_fft=N_FFT, \n",
131
- " win_length=N_FFT, \n",
132
- " hop_length=HOP_LEN\n",
133
- " ,\n",
134
- " center=True,\n",
135
- " pad_mode=\"reflect\",\n",
136
- " power=2.0,\n",
137
- " norm='slaney',\n",
138
- " onesided=True,\n",
139
- " n_mels=224,\n",
140
- " mel_scale=\"htk\"\n",
141
- " )(audio).mean(axis=0)\n",
142
  " specgram = torchaudio.transforms.AmplitudeToDB()(specgram)\n",
143
  " specgram = specgram - specgram.min()\n",
144
- " specgram = specgram/specgram.max()\n",
145
- " \n",
146
- " \n",
147
  " return specgram"
148
  ]
149
  },
 
87
  "metadata": {},
88
  "outputs": [],
89
  "source": [
90
+ "base_folder = Path(\"../input/kaggle-pog-series-s01e02\")\n",
91
  "\n",
92
+ "items = get_files(base_folder, extensions=\".ogg\")"
93
  ]
94
  },
95
  {
 
110
  }
111
  ],
112
  "source": [
113
+ "items"
114
  ]
115
  },
116
  {
 
126
  "\n",
127
  "def create_spectrogram(filename):\n",
128
  " audio, sr = torchaudio.load(filename)\n",
129
+ " specgram = torchaudio.transforms.MelSpectrogram(\n",
130
+ " sample_rate=sr,\n",
131
+ " n_fft=N_FFT,\n",
132
+ " win_length=N_FFT,\n",
133
+ " hop_length=HOP_LEN,\n",
134
+ " center=True,\n",
135
+ " pad_mode=\"reflect\",\n",
136
+ " power=2.0,\n",
137
+ " norm=\"slaney\",\n",
138
+ " onesided=True,\n",
139
+ " n_mels=224,\n",
140
+ " mel_scale=\"htk\",\n",
141
+ " )(audio).mean(axis=0)\n",
142
  " specgram = torchaudio.transforms.AmplitudeToDB()(specgram)\n",
143
  " specgram = specgram - specgram.min()\n",
144
+ " specgram = specgram / specgram.max()\n",
145
+ "\n",
 
146
  " return specgram"
147
  ]
148
  },
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
- fastai
2
- huggingface_hub
3
  torchaudio
 
 
1
+ fastai==2.6.0
2
+ gradio==2.9.4
3
  torchaudio
4
+ torchvision