Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
-
import soundfile as sf
|
4 |
-
import io
|
5 |
|
6 |
# --- Load models once at the beginning ---
|
7 |
image_to_text_model = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
|
@@ -29,10 +27,7 @@ def text2audio(story_text):
|
|
29 |
|
30 |
# play_audio
|
31 |
def play_audio(audio_data):
|
32 |
-
|
33 |
-
sf.write(audio_buffer, audio_data['audio'], audio_data['sampling_rate'], format='WAV')
|
34 |
-
audio_buffer.seek(0)
|
35 |
-
st.audio(audio_buffer, format='audio/wav')
|
36 |
|
37 |
# --- Streamlit App ---
|
38 |
st.set_page_config(page_title="Your Image to Audio Story", page_icon="🦜")
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
|
|
3 |
|
4 |
# --- Load models once at the beginning ---
|
5 |
image_to_text_model = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
|
|
|
27 |
|
28 |
# play_audio
|
29 |
def play_audio(audio_data):
|
30 |
+
st.audio(audio_data['audio'], format='audio/wav', sample_rate=audio_data['sampling_rate'])
|
|
|
|
|
|
|
31 |
|
32 |
# --- Streamlit App ---
|
33 |
st.set_page_config(page_title="Your Image to Audio Story", page_icon="🦜")
|