Spaces:
Runtime error
Runtime error
kurianbenoy
commited on
Commit
•
ef173f1
1
Parent(s):
ffada9a
Update nbs
Browse files- nbs/PytorchAudioInference.ipynb +18 -19
- requirements.txt +3 -2
nbs/PytorchAudioInference.ipynb
CHANGED
@@ -87,9 +87,9 @@
|
|
87 |
"metadata": {},
|
88 |
"outputs": [],
|
89 |
"source": [
|
90 |
-
"base_folder = Path(
|
91 |
"\n",
|
92 |
-
"items = get_files(base_folder, extensions
|
93 |
]
|
94 |
},
|
95 |
{
|
@@ -110,7 +110,7 @@
|
|
110 |
}
|
111 |
],
|
112 |
"source": [
|
113 |
-
"items
|
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(
|
130 |
-
"
|
131 |
-
"
|
132 |
-
"
|
133 |
-
"
|
134 |
-
"
|
135 |
-
"
|
136 |
-
"
|
137 |
-
"
|
138 |
-
"
|
139 |
-
"
|
140 |
-
"
|
141 |
-
"
|
142 |
" specgram = torchaudio.transforms.AmplitudeToDB()(specgram)\n",
|
143 |
" specgram = specgram - specgram.min()\n",
|
144 |
-
" specgram = specgram/specgram.max()\n",
|
145 |
-
"
|
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 |
-
|
3 |
torchaudio
|
|
|
|
1 |
+
fastai==2.6.0
|
2 |
+
gradio==2.9.4
|
3 |
torchaudio
|
4 |
+
torchvision
|