neha-ai-playground commited on
Commit
2382d71
·
1 Parent(s): 48f0586

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -5
app.py CHANGED
@@ -14,8 +14,7 @@ HF_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
14
  def img2Text(url):
15
  image_to_text = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
16
  text = image_to_text(url)[0]["generated_text"]
17
- st.subheader("Caption :")
18
- st.subheader(text)
19
  return text
20
 
21
  #llm
@@ -32,8 +31,7 @@ def generate_story(scenario):
32
  model_name="gpt-3.5-turbo", temperature=1), prompt=prompt, verbose=True)
33
 
34
  story = story_llm.predict(scenario=scenario)
35
- st.subheader("Story :")
36
- st.subheader(story)
37
  return story
38
 
39
  #textToSpeech
@@ -55,4 +53,30 @@ def text2Speech(story) :
55
 
56
  scenario = img2Text("photo.jpg")
57
  story = generate_story(scenario)
58
- text2Speech(story)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  def img2Text(url):
15
  image_to_text = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
16
  text = image_to_text(url)[0]["generated_text"]
17
+ print(text)
 
18
  return text
19
 
20
  #llm
 
31
  model_name="gpt-3.5-turbo", temperature=1), prompt=prompt, verbose=True)
32
 
33
  story = story_llm.predict(scenario=scenario)
34
+ print(story)
 
35
  return story
36
 
37
  #textToSpeech
 
53
 
54
  scenario = img2Text("photo.jpg")
55
  story = generate_story(scenario)
56
+ text2Speech(story)
57
+
58
+ def main()
59
+ st.set_page_config(page_title="Image to Short Story", page_icon="")
60
+ st.header("Turn img into Audio Story")
61
+ uploaded_file = st.file.uploader("Choose an image(jpg type)", type="jpg")
62
+ if uploaded_file is not None:
63
+ print(uploaded_file)
64
+ bytes_data = uploaded_file.getvalue()
65
+ with open(uploaded_file.name, "wb") as file:
66
+ file.write(bytes_data)
67
+ st.image(uploaded_file, caption= 'Uploaded Image.',
68
+ use_column_width=True)
69
+ scenario = img2Text(uploaded_file.name)
70
+ story = generate_story(scenario)
71
+ text2Speech(story)
72
+
73
+ with st.expander("scenario")
74
+ st.write(scenario)
75
+ with st.expander("story")
76
+ st.write(story)
77
+
78
+ st.audio("audio.flac")
79
+
80
+
81
+ if _name_ == '_main_';
82
+ main()