mimbres commited on
Commit
f84a254
1 Parent(s): 79b9c73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -15,9 +15,11 @@ import torchaudio
15
  import glob
16
  import gradio as gr
17
  from gradio_log import Log
 
18
 
19
  # gradio_log
20
  log_file = 'amt/log.txt'
 
21
 
22
  # @title Load Checkpoint
23
  model_name = 'YPTF.MoE+Multi (noPS)' # @param ["YMT3+", "YPTF+Single (noPS)", "YPTF+Multi (PS)", "YPTF.MoE+Multi (noPS)", "YPTF.MoE+Multi (PS)"]
@@ -74,9 +76,6 @@ def prepare_media(source_path_or_url: os.PathLike,
74
  # audio_file = mp4_file[:-3] + 'mp3'
75
  # subprocess.run(['ffmpeg', '-i', mp4_file, '-ac', '1', audio_file])
76
  # os.remove(mp4_file)
77
- # except Exception as e:
78
- # try:
79
- # try:
80
  with open(log_file, 'w') as lf:
81
  # Try alternative
82
  # print(f"Failed with PyTube, error: {e}. Trying yt-dlp...")
@@ -98,15 +97,13 @@ def prepare_media(source_path_or_url: os.PathLike,
98
  for line in iter(process.stdout.readline, ''):
99
  # Filter out unnecessary messages
100
  if "www.google.com/device" in line:
101
- lf.write(line)
102
- lf.flush()
 
103
  process.stdout.close()
104
  process.wait()
105
 
106
  audio_file += '.mp3'
107
- # except Exception as e:
108
- # print(f"Alternative downloader failed, error: {e}. Please try again later!")
109
- # return None
110
  else:
111
  raise ValueError(source_type)
112
 
@@ -144,12 +141,6 @@ def play_video(youtube_url):
144
  return None
145
  return create_html_youtube_player(youtube_url)
146
 
147
- def init_youtube_account():
148
- prepare_media("https://www.youtube.com/watch?v=vMboypSkj3c", 'youtube_url', simulate=True)
149
-
150
- # def display_log():
151
- # Log(log_file, tail=2, dark=True, xterm_font_size=12, elem_id='mylog') # gradio-log
152
-
153
 
154
  AUDIO_EXAMPLES = glob.glob('examples/*.*', recursive=True)
155
  YOUTUBE_EXAMPLES = ["https://youtu.be/5vJBhdjvVcE?si=s3NFG_SlVju0Iklg",
@@ -262,6 +253,5 @@ with gr.Blocks(theme=theme, css=css) as demo:
262
  # Play
263
  play_video_button.click(play_video, inputs=youtube_url, outputs=youtube_player)
264
  with gr.Column(scale=1):
265
- # init_youtube_account() # : dead..
266
  Log(log_file, dark=True, xterm_font_size=12, elem_id='mylog')
267
  demo.launch(debug=True)
 
15
  import glob
16
  import gradio as gr
17
  from gradio_log import Log
18
+ from pathlib import Path
19
 
20
  # gradio_log
21
  log_file = 'amt/log.txt'
22
+ Path(log_file).touch()
23
 
24
  # @title Load Checkpoint
25
  model_name = 'YPTF.MoE+Multi (noPS)' # @param ["YMT3+", "YPTF+Single (noPS)", "YPTF+Multi (PS)", "YPTF.MoE+Multi (noPS)", "YPTF.MoE+Multi (PS)"]
 
76
  # audio_file = mp4_file[:-3] + 'mp3'
77
  # subprocess.run(['ffmpeg', '-i', mp4_file, '-ac', '1', audio_file])
78
  # os.remove(mp4_file)
 
 
 
79
  with open(log_file, 'w') as lf:
80
  # Try alternative
81
  # print(f"Failed with PyTube, error: {e}. Trying yt-dlp...")
 
97
  for line in iter(process.stdout.readline, ''):
98
  # Filter out unnecessary messages
99
  if "www.google.com/device" in line:
100
+ hl_text = line.replace("https://www.google.com/device", "\033[93mhttps://www.google.com/device\x1b[0m").split()
101
+ hl_text[-1] = "\x1b[31;1m" + words[-1] + "\x1b[0m"
102
+ lf.write(' '.join(hl_line)); lf.flush()
103
  process.stdout.close()
104
  process.wait()
105
 
106
  audio_file += '.mp3'
 
 
 
107
  else:
108
  raise ValueError(source_type)
109
 
 
141
  return None
142
  return create_html_youtube_player(youtube_url)
143
 
 
 
 
 
 
 
144
 
145
  AUDIO_EXAMPLES = glob.glob('examples/*.*', recursive=True)
146
  YOUTUBE_EXAMPLES = ["https://youtu.be/5vJBhdjvVcE?si=s3NFG_SlVju0Iklg",
 
253
  # Play
254
  play_video_button.click(play_video, inputs=youtube_url, outputs=youtube_player)
255
  with gr.Column(scale=1):
 
256
  Log(log_file, dark=True, xterm_font_size=12, elem_id='mylog')
257
  demo.launch(debug=True)