Skip to content

Commit

Permalink
Adjust to show GIF animated
Browse files Browse the repository at this point in the history
  • Loading branch information
nparra75 committed Nov 26, 2024
1 parent 096d2cf commit 43b5697
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions UI/gif_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def generate_audio(text):
return audio_data

# Function to display audio and GIFs
def display_audio_and_caption(image, audio_bytes, caption, index):
st.image(image, caption=f"GIF {index + 1}", use_column_width=True)
def display_audio_and_caption(gif_data, audio_bytes, caption, index):
gif_html = f'<img src="data:image/gif;base64,{base64.b64encode(gif_data).decode()}" alt="GIF {index + 1}" style="max-width: 100%; height: auto;">'
st.markdown(gif_html, unsafe_allow_html=True)

audio_base64 = base64.b64encode(audio_bytes.read()).decode('utf-8')
audio_html = f"""
<audio controls>
Expand All @@ -45,7 +47,8 @@ def display_audio_and_caption(image, audio_bytes, caption, index):
uploaded_files = st.file_uploader("Upload one or more GIF files", type=["gif"], accept_multiple_files=True)
if uploaded_files:
for file in uploaded_files:
images.append(Image.open(file))
images.append(file.read())
#images.append(Image.open(file))

elif option == "Enter GIF URLs":
urls = st.text_area("Enter one or more GIF URLs (one per line)")
Expand All @@ -54,7 +57,8 @@ def display_audio_and_caption(image, audio_bytes, caption, index):
try:
response = requests.get(url.strip())
if response.status_code == 200:
images.append(Image.open(BytesIO(response.content)))
images.append(response.content)
#images.append(Image.open(BytesIO(response.content)))
except Exception as e:
st.error(f"Failed to load GIF from URL: {url}. Error: {e}")

Expand Down

0 comments on commit 43b5697

Please sign in to comment.