Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,31 +13,31 @@ def load_model():
|
|
| 13 |
def main():
|
| 14 |
caption = load_model()
|
| 15 |
st.title('Welcome to image to speech app')
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
if __name__ == '__main__' :
|
| 43 |
main()
|
|
|
|
| 13 |
def main():
|
| 14 |
caption = load_model()
|
| 15 |
st.title('Welcome to image to speech app')
|
| 16 |
+
instructions = """Click an image using inbuilt camera or upload an image file"""
|
| 17 |
+
st.write(instructions)
|
| 18 |
|
| 19 |
+
img = None
|
| 20 |
+
pictureCam = st.camera_input('Take a picture')
|
| 21 |
+
pictureUpload = st.file_uploader('Upload An Image')
|
| 22 |
|
| 23 |
+
if pictureCam :
|
| 24 |
+
st.write('clicked image from webcam')
|
| 25 |
+
st.image(pictureCam)
|
| 26 |
+
img = Image.open(pictureCam)
|
| 27 |
+
elif pictureUpload :
|
| 28 |
+
st.write('uploaded image from device')
|
| 29 |
+
st.image(pictureUpload)
|
| 30 |
+
img = Image.open(pictureUpload)
|
| 31 |
|
| 32 |
+
if img is not None :
|
| 33 |
+
description = caption(img)
|
| 34 |
+
generated_text = description[0]['generated_text']
|
| 35 |
+
st.write(generated_text)
|
| 36 |
+
generated_audio = gTTS(generated_text)
|
| 37 |
+
generated_audio.save('demo.mp3')
|
| 38 |
+
audio_file = open('demo.mp3', 'rb')
|
| 39 |
+
audio_bytes = audio_file.read()
|
| 40 |
+
st.audio(audio_bytes, format='audio/ogg',start_time=0)
|
| 41 |
|
| 42 |
if __name__ == '__main__' :
|
| 43 |
main()
|