Update app.py
Browse files
app.py
CHANGED
|
@@ -11,12 +11,14 @@ def img2text(url):
|
|
| 11 |
|
| 12 |
# text2story
|
| 13 |
def text2story(text):
|
| 14 |
-
story_text = ""
|
|
|
|
| 15 |
return story_text
|
| 16 |
|
| 17 |
# text2audio
|
| 18 |
def text2audio(story_text):
|
| 19 |
-
audio_data = ""
|
|
|
|
| 20 |
return audio_data
|
| 21 |
|
| 22 |
# main part
|
|
@@ -41,17 +43,17 @@ if uploaded_file is not None:
|
|
| 41 |
|
| 42 |
#Stage 2: Text to Story
|
| 43 |
st.text('Generating a story...')
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
#Stage 3: Story to Audio data
|
| 48 |
-
|
| 49 |
-
|
| 50 |
|
| 51 |
# Play button
|
| 52 |
if st.button("Play Audio"):
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
st.audio("kids_playing_audio.wav")
|
|
|
|
| 11 |
|
| 12 |
# text2story
|
| 13 |
def text2story(text):
|
| 14 |
+
story_text = pipeline("text2text-generation", model="google/flan-t5-large")
|
| 15 |
+
story_text = pipe(text)[0]['generated_text']
|
| 16 |
return story_text
|
| 17 |
|
| 18 |
# text2audio
|
| 19 |
def text2audio(story_text):
|
| 20 |
+
audio_data =pipeline("text-to-audio", model="facebook/musicgen-stereo-large")
|
| 21 |
+
audio_data = pipe(story_text)
|
| 22 |
return audio_data
|
| 23 |
|
| 24 |
# main part
|
|
|
|
| 43 |
|
| 44 |
#Stage 2: Text to Story
|
| 45 |
st.text('Generating a story...')
|
| 46 |
+
story = text2story(scenario)
|
| 47 |
+
st.write(story)
|
| 48 |
|
| 49 |
#Stage 3: Story to Audio data
|
| 50 |
+
st.text('Generating audio data...')
|
| 51 |
+
audio_data =text2audio(story)
|
| 52 |
|
| 53 |
# Play button
|
| 54 |
if st.button("Play Audio"):
|
| 55 |
+
st.audio(audio_data['audio'],
|
| 56 |
+
format="audio/wav",
|
| 57 |
+
start_time=0,
|
| 58 |
+
sample_rate = audio_data['sampling_rate'])
|
| 59 |
+
# st.audio("kids_playing_audio.wav")
|