Skip to content

Commit e640edc

Browse files
committed
Created using Colaboratory
1 parent 9c809d9 commit e640edc

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

SloppyUpsampler.ipynb

+28-10
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@
114114
" y = lfilter(b, a, data)\n",
115115
" return y\n",
116116
"\n",
117-
"def apply_highpass_mix(input, hipass_vol=0.5, mix_vol=0.8, cutoff=10000, fx=44100, order=6):\n",
117+
"def apply_highpass_mix(input, hipass_vol=0.5, mix_vol=0.8, cutoff=10000, fs=44100, order=6):\n",
118118
" if type(input) == np.ndarray:\n",
119119
" data = input\n",
120120
" sr = fs\n",
121121
" else:\n",
122122
" data, sr = librosa.load(input, sr=None, mono=False)\n",
123123
" octave_up = librosa.effects.pitch_shift(data, sr=sr, n_steps=12, res_type='soxr_vhq') * hipass_vol\n",
124-
" hipass = highpass_audio(octave_up, cutoff, fx, order)\n",
124+
" hipass = highpass_audio(octave_up, cutoff, fs, order)\n",
125125
" return data*mix_vol+hipass\n",
126126
"\n",
127127
"output.clear()\n",
@@ -149,7 +149,7 @@
149149
"\n",
150150
"#@markdown #### Changing anything below is not recommended.\n",
151151
"\n",
152-
"simulate_high_end = 0.2 #@param {type:\"slider\", min:0, max:0.5, step:0.05}\n",
152+
"simulate_high_end = 0.25 #@param {type:\"slider\", min:0, max:0.5, step:0.05}\n",
153153
"cutoff = 11000 #@param {type: \"number\"}\n",
154154
"mix_vol = 0.8 #@ param {type: \"number\"}\n",
155155
"\n",
@@ -184,28 +184,41 @@
184184
"# Output\n",
185185
"if output_dir == '':\n",
186186
" dir_out = dir_in\n",
187+
" op(c.warn, 'WARNING! You have not entered an output_dir')\n",
188+
" op(c.warn, '-> Files will be saved in the same directory where they are currently located.')\n",
187189
"else:\n",
188190
" if not os.path.isdir(drive_root+output_dir):\n",
189191
" os.mkdir(drive_root+output_dir)\n",
190192
" dir_out = drive_root+fix_path(output_dir)\n",
191193
" \n",
192194
"timer_start = time.time()\n",
193195
"total = len(inputs)\n",
196+
"op(c.title, 'Run ID:', uniq_id, time=True)\n",
194197
"\n",
195198
"# -- DO THINGS --\n",
196199
"for i, input in enumerate(inputs, 1):\n",
197200
"\n",
198-
" if i % 10: output.clear()\n",
199-
" \n",
201+
" if not i % 10:\n",
202+
" output.clear()\n",
203+
" op(c.warn, 'Cell output is cleared every 10 generations to keep Colab running smoothly.', time=True)\n",
204+
" op(c.warn, 'You can find all audio files from directory', dir_out.replace(drive_root, ''), time=True)\n",
205+
" print()\n",
206+
" op(c.title, 'Run ID:', uniq_id, time=True)\n",
207+
"\n",
208+
" print()\n",
200209
" ndx_info = str(i)+'/'+str(total)+' '\n",
201-
" op(c.title, ndx_info+'Processing', input.replace(drive_root, ''), time=True)\n",
210+
" op(c.title, ndx_info+'Processing', input.replace(drive_root, ''))\n",
211+
" print()\n",
202212
"\n",
203213
" file_tmp = dir_tmp+basename(input)+'.wav'\n",
214+
" if os.path.isfile(file_tmp): os.remove(file_tmp)\n",
204215
" file_out = dir_out+uniq_id+'_44khz_'+basename(input)+'.wav'\n",
205-
"\n",
216+
" \n",
206217
" if show_players == True: \n",
207-
" op(c.okb, 'Original audio')\n",
218+
" op(c.okb, 'Original audio:')\n",
219+
" print()\n",
208220
" audio_player(input)\n",
221+
" print()\n",
209222
"\n",
210223
" !ffmpeg -hide_banner -loglevel panic -i \"{input}\" -acodec {new_format} -ar {new_sr} \"{file_tmp}\"\n",
211224
" \n",
@@ -220,15 +233,20 @@
220233
" result = hpf2\n",
221234
"\n",
222235
" if show_players == True: \n",
223-
" op(c.okb, 'Upsampled audio')\n",
236+
" op(c.warn, 'Upsampled audio:')\n",
237+
" print()\n",
224238
" audio_player(result)\n",
239+
" print()\n",
225240
"\n",
226241
" sf.write(file_out, result.T, new_sr, subtype='PCM_24')\n",
227242
" if os.path.isfile(file_out):\n",
228243
" op(c.ok, 'Upsampled audio saved as', file_out.replace(drive_root, ''))\n",
229244
" else:\n",
230245
" op(c.fail, 'Error saving file', file_out)\n",
231246
" print()\n",
247+
"\n",
248+
" print()\n",
249+
" display(IPython.display.Markdown('---'))\n",
232250
"# -- END THINGS --\n",
233251
"\n",
234252
"timer_end = time.time()\n",
@@ -245,7 +263,7 @@
245263
"colab": {
246264
"provenance": [],
247265
"mount_file_id": "1KsC80bOcnAJ9K5UfpsF_saOywtPg7qT8",
248-
"authorship_tag": "ABX9TyOJCeccpZIzmdExU7GeEhRX",
266+
"authorship_tag": "ABX9TyN4bQzJfB0SgnFRUEPbtM/c",
249267
"include_colab_link": true
250268
},
251269
"kernelspec": {

0 commit comments

Comments
 (0)