mxiean commited on
Commit
1e78554
·
verified ·
1 Parent(s): dedc2b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -11,23 +11,22 @@ def img2text(url):
11
 
12
  # text2story
13
  def text2story(text):
14
- pipe = pipeline("text-generation", model="pranavpsv/gpt2-story-gen")
15
- story_text = pipe(text, max_length=100, num_return_sequences=1)[0]['generated_text']
16
  return story_text
17
 
18
  # text2audio
19
  def text2audio(story_text):
20
- pipe = pipeline("text-to-audio", model="Matthijs/mms-tts-nld")
21
  audio_data = pipe(story_text)
22
  return audio_data
23
 
24
- # main part
25
- # def main():
26
- st.set_page_config(page_title="Your Image to Audio Story",
27
- page_icon="🦜")
28
  st.header("Turn Your Image to Audio Story")
29
  uploaded_file = st.file_uploader("Select an Image...")
30
-
31
  if uploaded_file is not None:
32
  print(uploaded_file)
33
  bytes_data = uploaded_file.getvalue()
@@ -57,6 +56,6 @@ def text2audio(story_text):
57
  start_time=0,
58
  sample_rate = audio_data['sampling_rate'])
59
 
60
- # Run the main function
61
- # if __name__ == "__main__":
62
- # main()
 
11
 
12
  # text2story
13
  def text2story(text):
14
+ pipe = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")
15
+ story_text = pipe(text)[0]['generated_text']
16
  return story_text
17
 
18
  # text2audio
19
  def text2audio(story_text):
20
+ pipe = pipeline("text-to-audio", model="Matthijs/mms-tts-eng")
21
  audio_data = pipe(story_text)
22
  return audio_data
23
 
24
+
25
+ def main():
26
+ st.set_page_config(page_title="Your Image to Audio Story", page_icon="🦜")
 
27
  st.header("Turn Your Image to Audio Story")
28
  uploaded_file = st.file_uploader("Select an Image...")
29
+
30
  if uploaded_file is not None:
31
  print(uploaded_file)
32
  bytes_data = uploaded_file.getvalue()
 
56
  start_time=0,
57
  sample_rate = audio_data['sampling_rate'])
58
 
59
+
60
+ if __name__ == "__main__":
61
+ main()