Spaces:
Sleeping
Sleeping
add audio
Browse files
app.py
CHANGED
|
@@ -45,7 +45,9 @@ def generate_cocktail(mood, sweetness, sour, savory, bitter, flavor_association,
|
|
| 45 |
messages=messages,
|
| 46 |
max_tokens=1024)
|
| 47 |
name, quote, ingredients, instruction, notes = extract_info(response.choices[0].message.content)
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
except Exception as e:
|
| 50 |
return f'<p style="color: white; font-size: 20px;">{str(e)}</p>'
|
| 51 |
|
|
@@ -79,6 +81,9 @@ def format_cocktail_output(name, quote, ingredients, instruction, notes):
|
|
| 79 |
</div>
|
| 80 |
'''
|
| 81 |
return html_output
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# Creating the Gradio interface
|
| 84 |
with gr.Blocks(css='''
|
|
@@ -133,12 +138,23 @@ with gr.Blocks(css='''
|
|
| 133 |
|
| 134 |
with gr.Row():
|
| 135 |
output_recipe = gr.HTML(label="Your Cocktail Recipe")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
generate_button.click(
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
| 142 |
|
| 143 |
|
| 144 |
# sweetness .range-slider {background: #FAD02E;}
|
|
|
|
| 45 |
messages=messages,
|
| 46 |
max_tokens=1024)
|
| 47 |
name, quote, ingredients, instruction, notes = extract_info(response.choices[0].message.content)
|
| 48 |
+
play_button.update(visible=True) #modified
|
| 49 |
+
background_music_component.update(visible=True)
|
| 50 |
+
return format_cocktail_output(name, quote, ingredients, instruction, notes, play_button,background_music_component)
|
| 51 |
except Exception as e:
|
| 52 |
return f'<p style="color: white; font-size: 20px;">{str(e)}</p>'
|
| 53 |
|
|
|
|
| 81 |
</div>
|
| 82 |
'''
|
| 83 |
return html_output
|
| 84 |
+
|
| 85 |
+
def play_music():
|
| 86 |
+
return 'RPReplay_Final1712757356.mp3'
|
| 87 |
|
| 88 |
# Creating the Gradio interface
|
| 89 |
with gr.Blocks(css='''
|
|
|
|
| 138 |
|
| 139 |
with gr.Row():
|
| 140 |
output_recipe = gr.HTML(label="Your Cocktail Recipe")
|
| 141 |
+
|
| 142 |
+
play_button = gr.Button("Play Music", visible=False)
|
| 143 |
+
background_music_component = gr.Audio(label="Background Music", autoplay=True, visible=False)
|
| 144 |
+
|
| 145 |
|
| 146 |
+
# generate_button.click(
|
| 147 |
+
# fn=generate_cocktail,
|
| 148 |
+
# inputs=[mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests],
|
| 149 |
+
# outputs=output_recipe
|
| 150 |
+
# )
|
| 151 |
generate_button.click(
|
| 152 |
+
fn=generate_cocktail,
|
| 153 |
+
inputs=[mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests, play_button],
|
| 154 |
+
outputs=[output_recipe, play_button]
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
play_button.click(fn=play_music, inputs=[], outputs=background_music)
|
| 158 |
|
| 159 |
|
| 160 |
# sweetness .range-slider {background: #FAD02E;}
|