jhtonyKoo commited on
Commit
46ec003
1 Parent(s): 4460c7f

update yt_download

Browse files
__pycache__/inference.cpython-311.pyc CHANGED
Binary files a/__pycache__/inference.cpython-311.pyc and b/__pycache__/inference.cpython-311.pyc differ
 
__pycache__/utils.cpython-311.pyc CHANGED
Binary files a/__pycache__/utils.cpython-311.pyc and b/__pycache__/utils.cpython-311.pyc differ
 
app.py CHANGED
@@ -43,7 +43,7 @@ def loudness_normalize(audio, sample_rate, target_loudness=-12.0):
43
  def process_youtube_url(url):
44
  try:
45
  audio, sr = download_youtube_audio(url)
46
- return (sr, audio)
47
  except Exception as e:
48
  return None, f"Error processing YouTube URL: {str(e)}"
49
 
@@ -199,21 +199,23 @@ with gr.Blocks() as demo:
199
  gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB LUFS</span>')
200
 
201
  with gr.Row():
202
- output_audio_yt = gr.Audio(label="Output Audio", type='numpy')
203
- param_output_yt = gr.Textbox(label="Predicted Parameters", lines=5)
 
 
204
 
205
  error_message_yt = gr.Textbox(label="Error Message", visible=False)
206
 
207
  def process_and_handle_errors(input_audio, input_youtube_url, reference_audio, reference_youtube_url):
208
  result = process_audio_with_youtube(input_audio, input_youtube_url, reference_audio, reference_youtube_url)
209
  if len(result) == 3 and isinstance(result[2], str): # Error occurred
210
- return None, None, gr.update(visible=True, value=result[2])
211
- return result[0], result[1], gr.update(visible=False, value="")
212
 
213
  process_button_yt.click(
214
  process_and_handle_errors,
215
  inputs=[input_audio_yt, input_youtube_url, reference_audio_yt, reference_youtube_url],
216
- outputs=[output_audio_yt, param_output_yt, error_message_yt]
217
  )
218
 
219
  gr.Markdown("## Step 2: Inference Time Optimization (ITO)")
 
43
  def process_youtube_url(url):
44
  try:
45
  audio, sr = download_youtube_audio(url)
46
+ return (sr, audio), None
47
  except Exception as e:
48
  return None, f"Error processing YouTube URL: {str(e)}"
49
 
 
199
  gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB LUFS</span>')
200
 
201
  with gr.Row():
202
+ with gr.Column():
203
+ output_audio = gr.Audio(label="Output Audio y'", type='numpy')
204
+ normalized_input = gr.Audio(label="Normalized Source Audio", type='numpy')
205
+ param_output = gr.Textbox(label="Predicted Parameters", lines=5)
206
 
207
  error_message_yt = gr.Textbox(label="Error Message", visible=False)
208
 
209
  def process_and_handle_errors(input_audio, input_youtube_url, reference_audio, reference_youtube_url):
210
  result = process_audio_with_youtube(input_audio, input_youtube_url, reference_audio, reference_youtube_url)
211
  if len(result) == 3 and isinstance(result[2], str): # Error occurred
212
+ return None, None, None, gr.update(visible=True, value=result[2])
213
+ return result[0], result[1], result[2], gr.update(visible=False, value="")
214
 
215
  process_button_yt.click(
216
  process_and_handle_errors,
217
  inputs=[input_audio_yt, input_youtube_url, reference_audio_yt, reference_youtube_url],
218
+ outputs=[output_audio_yt, param_output_yt, normalized_input, error_message_yt]
219
  )
220
 
221
  gr.Markdown("## Step 2: Inference Time Optimization (ITO)")
modules/__pycache__/loss.cpython-311.pyc CHANGED
Binary files a/modules/__pycache__/loss.cpython-311.pyc and b/modules/__pycache__/loss.cpython-311.pyc differ
 
utils.py CHANGED
@@ -3,10 +3,11 @@ import librosa
3
  import numpy as np
4
 
5
  def download_youtube_audio(url):
6
- yt = YouTube(url, use_po_token=True)
 
7
  stream = yt.streams.filter(only_audio=True).first()
8
  filename = stream.download()
9
  audio, sr = librosa.load(filename, sr=44100, mono=False)
10
  if audio.ndim == 1:
11
  audio = np.stack([audio, audio])
12
- return audio.T
 
3
  import numpy as np
4
 
5
  def download_youtube_audio(url):
6
+ # yt = YouTube(url, use_po_token=True)
7
+ yt = YouTube(url)
8
  stream = yt.streams.filter(only_audio=True).first()
9
  filename = stream.download()
10
  audio, sr = librosa.load(filename, sr=44100, mono=False)
11
  if audio.ndim == 1:
12
  audio = np.stack([audio, audio])
13
+ return audio.T, sr