asmarx commited on
Commit
834a5a5
·
verified ·
1 Parent(s): a26dd44

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +1 -30
  2. requirements.txt +1 -4
app.py CHANGED
@@ -7,29 +7,6 @@ from youtube_transcript_api import YouTubeTranscriptApi
7
  from youtube_transcript_api.proxies import WebshareProxyConfig
8
  from gtts import gTTS
9
 
10
- # ---- FastAPI Proxy Setup ----
11
- from fastapi import FastAPI, Request
12
- from fastapi.responses import StreamingResponse
13
- import httpx
14
- import uvicorn
15
-
16
- fastapi_app = FastAPI()
17
-
18
- @fastapi_app.get("/proxy")
19
- async def proxy(url: str):
20
- async with httpx.AsyncClient() as client:
21
- r = await client.get(url, timeout=30.0, stream=True)
22
- if r.status_code != 200:
23
- return StreamingResponse(content=r.aiter_bytes(), status_code=r.status_code)
24
- headers = {
25
- "Content-Type": r.headers.get("content-type", "application/octet-stream"),
26
- "Access-Control-Allow-Origin": "*"
27
- }
28
- return StreamingResponse(r.aiter_bytes(), headers=headers)
29
-
30
-
31
- # ---- Your Existing Gradio App Below ----
32
-
33
  # Initialize YouTubeTranscriptApi
34
  proxy_username = os.environ.get('WEBSHARE_PROXY_UN')
35
  proxy_password = os.environ.get('WEBSHARE_PROXY_PW')
@@ -432,13 +409,7 @@ demo = gr.Interface(
432
  description="Enter a YouTube video ID and select a language to get the translated transcript and speech."
433
  )
434
 
435
- # ---- Launch Both Gradio and Proxy Server ----
436
- import multiprocessing
437
-
438
- def run_fastapi():
439
- uvicorn.run("app:fastapi_app", host="0.0.0.0", port=5001, log_level="info")
440
 
441
  if __name__ == "__main__":
442
- p = multiprocessing.Process(target=run_fastapi, daemon=True)
443
- p.start()
444
  demo.launch()
 
7
  from youtube_transcript_api.proxies import WebshareProxyConfig
8
  from gtts import gTTS
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Initialize YouTubeTranscriptApi
11
  proxy_username = os.environ.get('WEBSHARE_PROXY_UN')
12
  proxy_password = os.environ.get('WEBSHARE_PROXY_PW')
 
409
  description="Enter a YouTube video ID and select a language to get the translated transcript and speech."
410
  )
411
 
412
+ # ---- Launch Gradio ----
 
 
 
 
413
 
414
  if __name__ == "__main__":
 
 
415
  demo.launch()
requirements.txt CHANGED
@@ -6,7 +6,4 @@ gTTS
6
  requests
7
  torch
8
  sentencepiece
9
- accelerate
10
- fastapi
11
- uvicorn
12
- httpx
 
6
  requests
7
  torch
8
  sentencepiece
9
+ accelerate