Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
-
from io import BytesIO
|
| 4 |
from PIL import Image
|
| 5 |
-
import torch
|
| 6 |
|
| 7 |
# Load pipelines
|
| 8 |
image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
|
|
@@ -24,7 +22,8 @@ if uploaded_image:
|
|
| 24 |
|
| 25 |
# Convert text to speech
|
| 26 |
speech_output = text_to_speech(text_output)
|
| 27 |
-
audio_bytes = BytesIO(speech_output['audio'])
|
| 28 |
-
|
| 29 |
st.write("### Listen to Speech Output:")
|
| 30 |
-
st.audio(
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
from PIL import Image
|
|
|
|
| 4 |
|
| 5 |
# Load pipelines
|
| 6 |
image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
|
|
|
|
| 22 |
|
| 23 |
# Convert text to speech
|
| 24 |
speech_output = text_to_speech(text_output)
|
|
|
|
|
|
|
| 25 |
st.write("### Listen to Speech Output:")
|
| 26 |
+
st.audio(speech_output['audio'],
|
| 27 |
+
format="audio/wav",
|
| 28 |
+
start_time=0,
|
| 29 |
+
sample_rate = speech_output['sample_rate'])
|