Spaces:
Sleeping
Sleeping
Adarsh Shirawalmath
commited on
Commit
·
3406547
1
Parent(s):
1c1887e
upload
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from fastapi import FastAPI, HTTPException
|
|
|
2 |
from fastapi.responses import StreamingResponse
|
3 |
from pydantic import BaseModel, HttpUrl
|
4 |
import os
|
@@ -12,13 +13,21 @@ import io
|
|
12 |
import google.generativeai as genai
|
13 |
import time
|
14 |
from collections import deque
|
15 |
-
import uvicorn
|
16 |
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
logger = logging.getLogger(__name__)
|
19 |
|
20 |
app = FastAPI()
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
DEEPGRAM_API_KEY = "3aaf03ba25b82a4be7deb0a33968fa47a79536be"
|
23 |
deepgram = Deepgram(DEEPGRAM_API_KEY)
|
24 |
|
@@ -115,7 +124,7 @@ async def transcribe_video(video: VideoURL):
|
|
115 |
|
116 |
video_description = yt.description
|
117 |
|
118 |
-
audio_file = audio_stream.download(output_path="
|
119 |
audio_file_mp3 = audio_file + ".mp3"
|
120 |
os.rename(audio_file, audio_file_mp3)
|
121 |
|
@@ -170,7 +179,4 @@ async def chat_with_personality(chat_message: ChatMessage):
|
|
170 |
]
|
171 |
)
|
172 |
|
173 |
-
return {"response": response.choices[0].message.content.strip()}
|
174 |
-
|
175 |
-
if __name__ == "__main__":
|
176 |
-
uvicorn.run("main:app", host="0.0.0.0", port=int(os.getenv("PORT", 8000)))
|
|
|
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
|
|
|
13 |
import google.generativeai as genai
|
14 |
import time
|
15 |
from collections import deque
|
|
|
16 |
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
logger = logging.getLogger(__name__)
|
19 |
|
20 |
app = FastAPI()
|
21 |
|
22 |
+
# Add CORS middleware
|
23 |
+
app.add_middleware(
|
24 |
+
CORSMiddleware,
|
25 |
+
allow_origins=["*"], # Allows all origins
|
26 |
+
allow_credentials=True,
|
27 |
+
allow_methods=["*"], # Allows all methods
|
28 |
+
allow_headers=["*"], # Allows all headers
|
29 |
+
)
|
30 |
+
|
31 |
DEEPGRAM_API_KEY = "3aaf03ba25b82a4be7deb0a33968fa47a79536be"
|
32 |
deepgram = Deepgram(DEEPGRAM_API_KEY)
|
33 |
|
|
|
124 |
|
125 |
video_description = yt.description
|
126 |
|
127 |
+
audio_file = audio_stream.download(output_path="/tmp")
|
128 |
audio_file_mp3 = audio_file + ".mp3"
|
129 |
os.rename(audio_file, audio_file_mp3)
|
130 |
|
|
|
179 |
]
|
180 |
)
|
181 |
|
182 |
+
return {"response": response.choices[0].message.content.strip()}
|
|
|
|
|
|