tester1hf commited on
Commit
93a9462
·
verified ·
1 Parent(s): 296fbd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -99,6 +99,7 @@ def split_text(text, max_length=800):
99
  split_at = max_length
100
  chunks.append(text[:split_at])
101
  text = text[split_at:].lstrip()
 
102
  logger.debug(f"Split text into {len(chunks)} chunks")
103
  return chunks
104
 
@@ -318,16 +319,15 @@ if st.button("Создать видео"):
318
  with st.spinner("Генерация видео..."):
319
  video_filename = process_prompt(prompt)
320
  if video_filename:
321
- # Read video into memory before deletion
322
- try:
323
- with open(video_filename, "rb") as f:
324
- video_bytes = f.read()
325
- st.video(video_bytes)
326
- except Exception as e:
327
- st.error(f"Ошибка загрузки видео: {str(e)}")
328
- finally:
329
- if os.path.exists(video_filename):
330
- os.remove(video_filename)
331
  else:
332
  st.error("Не удалось создать видео.")
333
  else:
 
99
  split_at = max_length
100
  chunks.append(text[:split_at])
101
  text = text[split_at:].lstrip()
102
+ chunks.append(text)
103
  logger.debug(f"Split text into {len(chunks)} chunks")
104
  return chunks
105
 
 
319
  with st.spinner("Генерация видео..."):
320
  video_filename = process_prompt(prompt)
321
  if video_filename:
322
+ # Read the video file into memory as raw bytes
323
+ with open(video_filename, "rb") as video_file:
324
+ video_data = video_file.read()
325
+
326
+ # Display the video using raw data
327
+ st.video(video_data, format="video/mp4")
328
+
329
+ # Clean up the temporary video file
330
+ os.remove(video_filename)
 
331
  else:
332
  st.error("Не удалось создать видео.")
333
  else: