Adarsh Shirawalmath commited on
Commit
e963a2c
·
1 Parent(s): cdc15ae
Files changed (2) hide show
  1. app.py +2 -12
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,5 +1,4 @@
1
  from fastapi import FastAPI, HTTPException
2
- from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.responses import StreamingResponse
4
  from pydantic import BaseModel, HttpUrl
5
  import os
@@ -20,15 +19,6 @@ logger = logging.getLogger(__name__)
20
 
21
  app = FastAPI()
22
 
23
- # Add CORS middleware
24
- app.add_middleware(
25
- CORSMiddleware,
26
- allow_origins=["*"], # Allows all origins
27
- allow_credentials=True,
28
- allow_methods=["*"], # Allows all methods
29
- allow_headers=["*"], # Allows all headers
30
- )
31
-
32
  DEEPGRAM_API_KEY = "3aaf03ba25b82a4be7deb0a33968fa47a79536be"
33
  deepgram = Deepgram(DEEPGRAM_API_KEY)
34
 
@@ -118,14 +108,14 @@ def generate_quiz(text, video_description):
118
  @app.post("/transcribe")
119
  async def transcribe_video(video: VideoURL):
120
  try:
121
- yt = pytubefix.YouTube(str(video.url), use_oauth=True, allow_oauth_cache=True)
122
  audio_stream = yt.streams.filter(only_audio=True, file_extension='mp4').first()
123
  if not audio_stream:
124
  raise HTTPException(status_code=400, detail="No audio stream found for this video")
125
 
126
  video_description = yt.description
127
 
128
- audio_file = audio_stream.download(output_path="/tmp")
129
  audio_file_mp3 = audio_file + ".mp3"
130
  os.rename(audio_file, audio_file_mp3)
131
 
 
1
  from fastapi import FastAPI, HTTPException
 
2
  from fastapi.responses import StreamingResponse
3
  from pydantic import BaseModel, HttpUrl
4
  import os
 
19
 
20
  app = FastAPI()
21
 
 
 
 
 
 
 
 
 
 
22
  DEEPGRAM_API_KEY = "3aaf03ba25b82a4be7deb0a33968fa47a79536be"
23
  deepgram = Deepgram(DEEPGRAM_API_KEY)
24
 
 
108
  @app.post("/transcribe")
109
  async def transcribe_video(video: VideoURL):
110
  try:
111
+ yt = pytubefix.YouTube(str(video.url))
112
  audio_stream = yt.streams.filter(only_audio=True, file_extension='mp4').first()
113
  if not audio_stream:
114
  raise HTTPException(status_code=400, detail="No audio stream found for this video")
115
 
116
  video_description = yt.description
117
 
118
+ audio_file = audio_stream.download(output_path="temp")
119
  audio_file_mp3 = audio_file + ".mp3"
120
  os.rename(audio_file, audio_file_mp3)
121
 
requirements.txt CHANGED
@@ -5,4 +5,5 @@ openai
5
  deepgram-sdk==2.12.0
6
  google-generativeai
7
  uvicorn
8
- gunicorn
 
 
5
  deepgram-sdk==2.12.0
6
  google-generativeai
7
  uvicorn
8
+ gunicorn
9
+ firebase_admin