wh1223 commited on
Commit
6efa823
·
verified ·
1 Parent(s): ef99dbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -11,18 +11,19 @@ def img2text(url):
11
  # text2story
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']
19
  return story_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",
@@ -49,8 +50,8 @@ if uploaded_file is not None:
49
  st.write(story)
50
 
51
  #Stage 3: Story to Audio data
52
- #st.text('Generating audio data...')
53
- #audio_data =text2audio(story)
54
 
55
  # Play button
56
  if st.button("Play Audio"):
 
11
  # text2story
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
+ messages = "Generate a 100-word story based on the following keywords:" + text
18
+ text_to_story_model= pipeline("text2text-generation", model="google/flan-t5-small")
19
  story_text = text_to_story_model(messages)[0]['generated_text']
20
  return story_text
21
 
22
  # text2audio
23
  def text2audio(story_text):
24
+ text_to_audio_model = pipeline("text-to-speech", model="facebook/mms-tts-eng")
25
  #audio_data = "" # to be completed
26
+ audio_data = text_to_audio_model(story_text)
27
  return audio_data
28
 
29
  st.set_page_config(page_title="Your Image to Audio Story",
 
50
  st.write(story)
51
 
52
  #Stage 3: Story to Audio data
53
+ st.text('Generating audio data...')
54
+ audio_data =text2audio(story)
55
 
56
  # Play button
57
  if st.button("Play Audio"):