Spaces:
Running
Running
Rename app3.py to app.py
Browse files- app3.py → app.py +2 -24
app3.py → app.py
RENAMED
@@ -10,10 +10,7 @@ from dotenv import load_dotenv
|
|
10 |
from openai import OpenAI
|
11 |
import assemblyai as aai
|
12 |
|
13 |
-
|
14 |
-
load_dotenv()
|
15 |
-
aai.settings.api_key = os.getenv("ASSEMBLYAI_API_KEY")
|
16 |
-
OpenAI.api_key = os.getenv("OPENAI_API_KEY")
|
17 |
client = OpenAI()
|
18 |
|
19 |
def extract_recent_frames(video_url, output_folder, duration=10, frames_per_second=1):
|
@@ -83,26 +80,7 @@ def main():
|
|
83 |
st.error("Failed to extract frames.")
|
84 |
|
85 |
#####################33
|
86 |
-
|
87 |
-
try:
|
88 |
-
prompt_messages = [
|
89 |
-
{
|
90 |
-
"role": "user",
|
91 |
-
"content": [
|
92 |
-
"1. Generate a description for this sequence of video frames in about 90 words. Return the following: 1. List of objects in the video 2. Any restrictive content or sensitive content and if so which frame.",
|
93 |
-
*map(lambda x: {"image": x, "resize": 428}, base64_frames[0::30]),
|
94 |
-
],
|
95 |
-
},
|
96 |
-
]
|
97 |
-
response = client.chat.completions.create(
|
98 |
-
model="gpt-4-vision-preview",
|
99 |
-
messages=prompt_messages,
|
100 |
-
max_tokens=3000,
|
101 |
-
)
|
102 |
-
return response.choices[0].message.content
|
103 |
-
except Exception as e:
|
104 |
-
print(f"Error in generate_description: {e}")
|
105 |
-
return None
|
106 |
|
107 |
#########################################3333
|
108 |
|
|
|
10 |
from openai import OpenAI
|
11 |
import assemblyai as aai
|
12 |
|
13 |
+
|
|
|
|
|
|
|
14 |
client = OpenAI()
|
15 |
|
16 |
def extract_recent_frames(video_url, output_folder, duration=10, frames_per_second=1):
|
|
|
80 |
st.error("Failed to extract frames.")
|
81 |
|
82 |
#####################33
|
83 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
#########################################3333
|
86 |
|