adi-123 commited on
Commit
bb2d7b1
·
1 Parent(s): 7b3510a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -35,14 +35,15 @@ def txt2story(img_text):
35
  {"role": "user", "content": f"Here is input set of words: {img_text}", "temperature": 1},
36
  ]
37
 
38
- print("Generating story completion using the AI model...")
39
  chat_completion = client.chat.completions.create(
40
  messages=messages,
41
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
42
  max_tokens=200)
43
-
44
- return chat_completion.choices[0].message.content
45
  print(chat_completion.choices[0].message.content)
 
 
46
 
47
 
48
  # Text-to-speech
@@ -52,16 +53,12 @@ def txt2speech(text):
52
  headers = {"Authorization": f"Bearer {os.environ['HUGGINGFACEHUB_API_TOKEN']}"}
53
  payloads = {'inputs': text}
54
 
55
- print("Sending request for speech synthesis...")
56
  response = requests.post(API_URL, headers=headers, json=payloads)
57
 
58
- print("Saving synthesized speech to audio file...")
59
  with open('audio_story.mp3', 'wb') as file:
60
  file.write(response.content)
61
-
62
- print("Text-to-speech conversion completed.")
63
-
64
 
 
65
  # Streamlit web app main function
66
  def main():
67
  st.set_page_config(page_title="🎨 Image-to-Audio Story 🎧", page_icon="🖼️")
 
35
  {"role": "user", "content": f"Here is input set of words: {img_text}", "temperature": 1},
36
  ]
37
 
38
+ print("Story...")
39
  chat_completion = client.chat.completions.create(
40
  messages=messages,
41
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
42
  max_tokens=200)
43
+
 
44
  print(chat_completion.choices[0].message.content)
45
+ return chat_completion.choices[0].message.content
46
+
47
 
48
 
49
  # Text-to-speech
 
53
  headers = {"Authorization": f"Bearer {os.environ['HUGGINGFACEHUB_API_TOKEN']}"}
54
  payloads = {'inputs': text}
55
 
 
56
  response = requests.post(API_URL, headers=headers, json=payloads)
57
 
 
58
  with open('audio_story.mp3', 'wb') as file:
59
  file.write(response.content)
 
 
 
60
 
61
+
62
  # Streamlit web app main function
63
  def main():
64
  st.set_page_config(page_title="🎨 Image-to-Audio Story 🎧", page_icon="🖼️")