Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +23 -0
src/streamlit_app.py
CHANGED
|
@@ -132,6 +132,29 @@ if audio_shopping_list is not None: #Receive shopping list input
|
|
| 132 |
|
| 133 |
if audio_shopping_list is not None and shopping_list != '':
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
image_file = st.file_uploader("Upload a picture of your current position", type=['png','jpg','jpeg'])
|
| 136 |
|
| 137 |
if image_file is not None:
|
|
|
|
| 132 |
|
| 133 |
if audio_shopping_list is not None and shopping_list != '':
|
| 134 |
|
| 135 |
+
payload = {
|
| 136 |
+
"model": model,
|
| 137 |
+
"messages": [{"role": "system",
|
| 138 |
+
"content": [{
|
| 139 |
+
"type": "text",
|
| 140 |
+
"text": system_prompt}]
|
| 141 |
+
},
|
| 142 |
+
{"role": "user",
|
| 143 |
+
"content": [{
|
| 144 |
+
"type": "text",
|
| 145 |
+
"text": f"Hello! I need help finding {shopping_list}."}]
|
| 146 |
+
}]
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 150 |
+
|
| 151 |
+
text_to_speech(response.json()["choices"][0]["message"]["content"], speech_file_path)
|
| 152 |
+
|
| 153 |
+
st.markdown(response.json()["choices"][0]["message"]["content"])
|
| 154 |
+
|
| 155 |
+
audio_bytes = open(speech_file_path, 'rb').read()
|
| 156 |
+
st.audio(audio_bytes, format='audio/mp3', autoplay=True)
|
| 157 |
+
|
| 158 |
image_file = st.file_uploader("Upload a picture of your current position", type=['png','jpg','jpeg'])
|
| 159 |
|
| 160 |
if image_file is not None:
|