Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -164,14 +164,14 @@ def extract_video_frames(video_path, seconds_per_frame=2):
|
|
164 |
|
165 |
# Function to process audio for video
|
166 |
def process_audio_for_video(video_input):
|
167 |
-
try:
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
except:
|
174 |
-
|
175 |
|
176 |
# Function to process text with selected model
|
177 |
def process_text(user_name, text_input, selected_model, temp_values):
|
@@ -194,21 +194,21 @@ def process_text(user_name, text_input, selected_model, temp_values):
|
|
194 |
)
|
195 |
return_text = st.write_stream(completion)
|
196 |
else:
|
197 |
-
try:
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
except Exception as e:
|
210 |
-
|
211 |
-
|
212 |
|
213 |
st.markdown(f"Assistant ({timestamp}): {return_text}")
|
214 |
filename = generate_filename(text_input, "md")
|
|
|
164 |
|
165 |
# Function to process audio for video
|
166 |
def process_audio_for_video(video_input):
|
167 |
+
#try:
|
168 |
+
transcription = client.audio.transcriptions.create(
|
169 |
+
model="whisper-1",
|
170 |
+
file=video_input,
|
171 |
+
)
|
172 |
+
return transcription.text
|
173 |
+
#except:
|
174 |
+
# return ''
|
175 |
|
176 |
# Function to process text with selected model
|
177 |
def process_text(user_name, text_input, selected_model, temp_values):
|
|
|
194 |
)
|
195 |
return_text = st.write_stream(completion)
|
196 |
else:
|
197 |
+
#try:
|
198 |
+
stream = hf_client.chat.completions.create(
|
199 |
+
model=model_links[selected_model],
|
200 |
+
messages=[
|
201 |
+
{"role": m["role"], "content": m["content"]}
|
202 |
+
for m in st.session_state.messages
|
203 |
+
],
|
204 |
+
temperature=temp_values,
|
205 |
+
stream=True,
|
206 |
+
max_tokens=3000,
|
207 |
+
)
|
208 |
+
return_text = st.write_stream(stream)
|
209 |
+
#except Exception as e:
|
210 |
+
# return_text = f"Error: {str(e)}"
|
211 |
+
# st.error(return_text)
|
212 |
|
213 |
st.markdown(f"Assistant ({timestamp}): {return_text}")
|
214 |
filename = generate_filename(text_input, "md")
|