Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,20 +8,12 @@ from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
|
| 8 |
from transformers import set_seed
|
| 9 |
import random
|
| 10 |
|
| 11 |
-
|
| 12 |
-
import pyttsx3
|
| 13 |
-
from gtts import gTTS
|
| 14 |
-
import os
|
| 15 |
-
|
| 16 |
-
|
| 17 |
import nltk
|
| 18 |
from nltk.corpus import stopwords
|
| 19 |
from nltk.tokenize import sent_tokenize, word_tokenize
|
| 20 |
from nltk.probability import FreqDist
|
| 21 |
from nltk import download
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
# Download NLTK data (if not already downloaded)
|
| 26 |
download('punkt')
|
| 27 |
download('stopwords')
|
|
@@ -1275,13 +1267,6 @@ st.write()
|
|
| 1275 |
st.markdown("""---""")
|
| 1276 |
st.write()
|
| 1277 |
|
| 1278 |
-
|
| 1279 |
-
def read_recipe_aloud(recipe):
|
| 1280 |
-
tts = gTTS(text=recipe, lang='en')
|
| 1281 |
-
tts.save("recipe.mp3")
|
| 1282 |
-
os.system("mpg321 recipe.mp3")
|
| 1283 |
-
|
| 1284 |
-
|
| 1285 |
if my_upload is not None:
|
| 1286 |
st.image(my_upload, caption="Uploaded Image", use_column_width=True)
|
| 1287 |
|
|
@@ -1320,27 +1305,26 @@ if st.button("Generate Recipe"):
|
|
| 1320 |
title = selected_entry["title"]
|
| 1321 |
ingredients = selected_entry["ingredients"]
|
| 1322 |
recipe = selected_entry["recipe"]
|
|
|
|
| 1323 |
else:
|
| 1324 |
title = "Default Recipe Title"
|
| 1325 |
ingredients = []
|
| 1326 |
recipe = "No recipe found for this item."
|
|
|
|
| 1327 |
|
| 1328 |
st.write(f"Generated Recipe for {title}:\n")
|
| 1329 |
st.write(f"Ingredients: {', '.join(ingredients)}")
|
| 1330 |
st.write(f"Instructions: {recipe}")
|
| 1331 |
|
| 1332 |
-
|
| 1333 |
-
# Add a button to trigger the voice function
|
| 1334 |
-
if st.button("voice"):
|
| 1335 |
-
read_recipe_aloud(recipe)
|
| 1336 |
-
|
| 1337 |
-
|
| 1338 |
-
|
| 1339 |
# Generate and display the recipe summary
|
| 1340 |
st.write("Recipe Summary:")
|
| 1341 |
recipe_summary = generate_summary(recipe)
|
| 1342 |
st.write(recipe_summary)
|
| 1343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1344 |
# Add some descriptions and instructions
|
| 1345 |
st.sidebar.markdown("### Instructions")
|
| 1346 |
st.sidebar.markdown("1. Upload an image.")
|
|
|
|
| 8 |
from transformers import set_seed
|
| 9 |
import random
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
import nltk
|
| 12 |
from nltk.corpus import stopwords
|
| 13 |
from nltk.tokenize import sent_tokenize, word_tokenize
|
| 14 |
from nltk.probability import FreqDist
|
| 15 |
from nltk import download
|
| 16 |
|
|
|
|
|
|
|
| 17 |
# Download NLTK data (if not already downloaded)
|
| 18 |
download('punkt')
|
| 19 |
download('stopwords')
|
|
|
|
| 1267 |
st.markdown("""---""")
|
| 1268 |
st.write()
|
| 1269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1270 |
if my_upload is not None:
|
| 1271 |
st.image(my_upload, caption="Uploaded Image", use_column_width=True)
|
| 1272 |
|
|
|
|
| 1305 |
title = selected_entry["title"]
|
| 1306 |
ingredients = selected_entry["ingredients"]
|
| 1307 |
recipe = selected_entry["recipe"]
|
| 1308 |
+
youtube_link = f"https://www.youtube.com/results?search_query={title}+recipe"
|
| 1309 |
else:
|
| 1310 |
title = "Default Recipe Title"
|
| 1311 |
ingredients = []
|
| 1312 |
recipe = "No recipe found for this item."
|
| 1313 |
+
youtube_link = ""
|
| 1314 |
|
| 1315 |
st.write(f"Generated Recipe for {title}:\n")
|
| 1316 |
st.write(f"Ingredients: {', '.join(ingredients)}")
|
| 1317 |
st.write(f"Instructions: {recipe}")
|
| 1318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1319 |
# Generate and display the recipe summary
|
| 1320 |
st.write("Recipe Summary:")
|
| 1321 |
recipe_summary = generate_summary(recipe)
|
| 1322 |
st.write(recipe_summary)
|
| 1323 |
|
| 1324 |
+
# Display YouTube link
|
| 1325 |
+
st.write(f"YouTube Recipe Link: [{title} Recipe]({youtube_link})")
|
| 1326 |
+
|
| 1327 |
+
|
| 1328 |
# Add some descriptions and instructions
|
| 1329 |
st.sidebar.markdown("### Instructions")
|
| 1330 |
st.sidebar.markdown("1. Upload an image.")
|