Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ def img2text(url):
|
|
| 12 |
def text2story(text):
|
| 13 |
#story_text = "" # to be completed
|
| 14 |
messages = [
|
| 15 |
-
{"role": "user", "content": "
|
| 16 |
]
|
| 17 |
text_to_story_model= pipeline("text-generation", model="microsoft/Phi-4-mini-instruct", trust_remote_code=True)
|
| 18 |
story_text = text_to_story_model(messages)[0]['generated_text']
|
|
@@ -20,7 +20,9 @@ def text2story(text):
|
|
| 20 |
|
| 21 |
# text2audio
|
| 22 |
def text2audio(story_text):
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
return audio_data
|
| 25 |
|
| 26 |
st.set_page_config(page_title="Your Image to Audio Story",
|
|
@@ -52,8 +54,8 @@ if uploaded_file is not None:
|
|
| 52 |
|
| 53 |
# Play button
|
| 54 |
if st.button("Play Audio"):
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
st.audio("kids_playing_audio.wav")
|
|
|
|
| 12 |
def text2story(text):
|
| 13 |
#story_text = "" # to be completed
|
| 14 |
messages = [
|
| 15 |
+
{"role": "user", "content": "Generate a 100-word story based on the following keywords:"+text },
|
| 16 |
]
|
| 17 |
text_to_story_model= pipeline("text-generation", model="microsoft/Phi-4-mini-instruct", trust_remote_code=True)
|
| 18 |
story_text = text_to_story_model(messages)[0]['generated_text']
|
|
|
|
| 20 |
|
| 21 |
# text2audio
|
| 22 |
def text2audio(story_text):
|
| 23 |
+
text_to_video_model = pipeline("text-to-speech", model="facebook/mms-tts-eng")
|
| 24 |
+
#audio_data = "" # to be completed
|
| 25 |
+
audio_data = text_to_video_model(story_text)
|
| 26 |
return audio_data
|
| 27 |
|
| 28 |
st.set_page_config(page_title="Your Image to Audio Story",
|
|
|
|
| 54 |
|
| 55 |
# Play button
|
| 56 |
if st.button("Play Audio"):
|
| 57 |
+
st.audio(audio_data['audio'],
|
| 58 |
+
format="audio/wav",
|
| 59 |
+
start_time=0,
|
| 60 |
+
sample_rate = audio_data['sampling_rate'])
|
| 61 |
+
#st.audio("kids_playing_audio.wav")
|