Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import time
|
|
@@ -11,10 +12,26 @@ asr = pipeline("automatic-speech-recognition", model="distil-whisper/distil-smal
|
|
| 11 |
# Summarization model
|
| 12 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def process_youtube_link(youtube_url):
|
| 15 |
try:
|
| 16 |
-
print(youtube_url)
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
title = yt.title
|
| 19 |
print(f"Downloading: {title}")
|
| 20 |
|
|
@@ -57,4 +74,3 @@ iface = gr.Interface(
|
|
| 57 |
)
|
| 58 |
|
| 59 |
iface.launch()
|
| 60 |
-
|
|
|
|
| 1 |
+
import requests
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
import time
|
|
|
|
| 12 |
# Summarization model
|
| 13 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 14 |
|
| 15 |
+
# Function to fetch PO Token from the Node.js server
|
| 16 |
+
def get_po_token():
|
| 17 |
+
try:
|
| 18 |
+
response = requests.get("http://localhost:3001/get-token") # Call Node.js API
|
| 19 |
+
response.raise_for_status()
|
| 20 |
+
return response.json().get("poToken") # Extract token
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print(f"Error fetching PO token: {e}")
|
| 23 |
+
return None # Return None if the request fails
|
| 24 |
+
|
| 25 |
def process_youtube_link(youtube_url):
|
| 26 |
try:
|
| 27 |
+
print(f"Received YouTube URL: {youtube_url}") # Debugging
|
| 28 |
+
|
| 29 |
+
po_token = get_po_token()
|
| 30 |
+
if not po_token:
|
| 31 |
+
return "Error: Unable to fetch PO token.", ""
|
| 32 |
+
|
| 33 |
+
# Use the token with pytubefix
|
| 34 |
+
yt = YouTube(youtube_url, po_token=po_token)
|
| 35 |
title = yt.title
|
| 36 |
print(f"Downloading: {title}")
|
| 37 |
|
|
|
|
| 74 |
)
|
| 75 |
|
| 76 |
iface.launch()
|
|
|