Ubuntu commited on
Commit
71ee1ab
·
1 Parent(s): 7b125b8
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -15,7 +15,7 @@ def download_youtube_audio(url: str, output_dir: Optional[str] = None) -> str:
15
  output_dir = tempfile.gettempdir()
16
 
17
  yt_dlp_command = [
18
- "yt-dlp",
19
  "-f", "bestaudio/best",
20
  "-x", # Extract audio
21
  "--audio-format", "mp3",
@@ -23,6 +23,8 @@ def download_youtube_audio(url: str, output_dir: Optional[str] = None) -> str:
23
  "-o", os.path.join(output_dir, "%(id)s.%(ext)s"),
24
  "-v",
25
  "--print", "after_move:filepath", # Print the output filepath
 
 
26
  "--no-playlist",
27
  "--print-json",
28
  url
@@ -76,10 +78,10 @@ def run_asr(audio_file, youtube_url):
76
  def embed_youtube(youtube_url):
77
  if youtube_url:
78
  try:
79
- #video_id = YoutubeDL().extract_info(youtube_url, download=False)['id']\
80
  video_id = youtube_url.split("v=")[1]
81
- if 'shorts' in youtube_url:
82
- video_id = youtube_url.split('/')[-1]
83
  print(video_id)
84
  embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
85
  return gr.update(value=embed_html, visible=True), "", None
@@ -134,4 +136,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
134
  gr.Markdown("5. Wait for a few seconds, and your transcription will appear in the result box.")
135
 
136
  # Launch the Gradio interface
137
- demo.launch()
 
 
 
 
 
 
 
15
  output_dir = tempfile.gettempdir()
16
 
17
  yt_dlp_command = [
18
+ "/home/ubuntu/miniconda3/envs/gradio_whisper/bin/yt-dlp",
19
  "-f", "bestaudio/best",
20
  "-x", # Extract audio
21
  "--audio-format", "mp3",
 
23
  "-o", os.path.join(output_dir, "%(id)s.%(ext)s"),
24
  "-v",
25
  "--print", "after_move:filepath", # Print the output filepath
26
+ "--username", "oauth2",
27
+ "--password", "",
28
  "--no-playlist",
29
  "--print-json",
30
  url
 
78
  def embed_youtube(youtube_url):
79
  if youtube_url:
80
  try:
81
+ # video_id = YoutubeDL().extract_info(youtube_url, download=False)['id']\
82
  video_id = youtube_url.split("v=")[1]
83
+ if 'short' in youtube_url:
84
+ video_id = video_id.split("/")[-1]
85
  print(video_id)
86
  embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
87
  return gr.update(value=embed_html, visible=True), "", None
 
136
  gr.Markdown("5. Wait for a few seconds, and your transcription will appear in the result box.")
137
 
138
  # Launch the Gradio interface
139
+ demo.launch(
140
+ server_name='0.0.0.0',
141
+ server_port=5008,
142
+ ssl_certfile='/home/ubuntu/astarwiz_com/astarwiz_com.crt',
143
+ ssl_keyfile='/home/ubuntu/astarwiz_com/astarwiz_com.key',
144
+ ssl_verify=False
145
+ )