Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,10 @@ from transformers import pipeline
|
|
| 3 |
from gtts import gTTS
|
| 4 |
from PIL import Image
|
| 5 |
import time
|
| 6 |
-
#from playsound import playsound
|
| 7 |
-
#from pydub import AudioSegment
|
| 8 |
-
#from preferredsoundplayer import soundplay
|
| 9 |
|
| 10 |
-
#@st.cache()
|
| 11 |
@st.cache(allow_output_mutation=True)
|
| 12 |
def load_model():
|
| 13 |
-
|
| 14 |
model = pipeline('image-to-text')
|
| 15 |
return model
|
| 16 |
|
|
@@ -40,29 +36,8 @@ def main():
|
|
| 40 |
st.write(generated_text)
|
| 41 |
generated_audio = gTTS(generated_text)
|
| 42 |
generated_audio.save('demo.mp3')
|
| 43 |
-
|
| 44 |
audio_file = open(‘demo.mp3’, ‘rb’)
|
| 45 |
audio_bytes = audio_file.read()
|
| 46 |
st.audio(audio_bytes, format=‘audio/ogg’,start_time=0)
|
| 47 |
-
|
| 48 |
-
#html_string = """
|
| 49 |
-
#<audio controls autoplay>
|
| 50 |
-
# <source src="demo.mp3" type="audio/mp3">
|
| 51 |
-
#</audio>
|
| 52 |
-
#"""
|
| 53 |
-
#sound = st.empty()
|
| 54 |
-
#sound.markdown(html_string, unsafe_allow_html=True) # will display a st.audio with the sound you specified in the "src" of the html_string and autoplay it
|
| 55 |
-
#time.sleep(2) # wait for 2 seconds to finish the playing of the audio
|
| 56 |
-
#sound.empty() # optionally delete the element afterwards
|
| 57 |
-
|
| 58 |
-
#sound = AudioSegment.from_mp3("demo.mp3")
|
| 59 |
-
#sound.export("demo.wav", format="wav")
|
| 60 |
-
#soundplay("demo.mp3")
|
| 61 |
-
#playsound('demo.mp3')
|
| 62 |
-
#audio_file = open('demo.wav', 'rb')
|
| 63 |
-
#audio_bytes = audio_file.read()
|
| 64 |
-
#st.audio(audio_bytes, format='audio/wav')
|
| 65 |
-
|
| 66 |
-
|
| 67 |
if __name__ == '__main__' :
|
| 68 |
main()
|
|
|
|
| 3 |
from gtts import gTTS
|
| 4 |
from PIL import Image
|
| 5 |
import time
|
|
|
|
|
|
|
|
|
|
| 6 |
|
|
|
|
| 7 |
@st.cache(allow_output_mutation=True)
|
| 8 |
def load_model():
|
| 9 |
+
"""Retrieves the trained model"""
|
| 10 |
model = pipeline('image-to-text')
|
| 11 |
return model
|
| 12 |
|
|
|
|
| 36 |
st.write(generated_text)
|
| 37 |
generated_audio = gTTS(generated_text)
|
| 38 |
generated_audio.save('demo.mp3')
|
|
|
|
| 39 |
audio_file = open(‘demo.mp3’, ‘rb’)
|
| 40 |
audio_bytes = audio_file.read()
|
| 41 |
st.audio(audio_bytes, format=‘audio/ogg’,start_time=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
if __name__ == '__main__' :
|
| 43 |
main()
|