putan1122 commited on
Commit
57b710d
·
verified ·
1 Parent(s): c449d29

add music shuffle

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -5,13 +5,26 @@ import re
5
  from datetime import datetime
6
  import openai
7
  import pdfkit
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Function to play background music
10
  def play_music():
11
  """Returns the path to the music file and makes the audio player visible."""
12
- music_path = "RPReplay_Final1712757356.mp3"
13
  return music_path, gr.update(visible=True)
14
 
 
15
  # Main function to generate a cocktail recipe based on user preferences
16
  def generate_cocktail(mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests):
17
  """Generates a cocktail recipe using OpenAI's GPT-4 based on user input."""
@@ -139,4 +152,4 @@ if __name__ == "__main__":
139
  demo.launch(#enable_queue=False,
140
  # Creates an auth screen
141
  auth_message="Welcome! Enter a Username and Password"
142
- ).queue()
 
5
  from datetime import datetime
6
  import openai
7
  import pdfkit
8
+ import random
9
+
10
+
11
+ music_files = [
12
+ "RPReplay_Final1712757356.mp3",
13
+ "RPReplay_Final1712801927.mp3",
14
+ "RPReplay_Final1712802362.mp3",
15
+ "RPReplay_Final1712802406.mp3",
16
+ "RPReplay_Final1712757356.mp3",
17
+ "RPReplay_Final1712802448.mp3",
18
+ "RPReplay_Final1712802599.mp3"
19
+ ]
20
 
21
  # Function to play background music
22
  def play_music():
23
  """Returns the path to the music file and makes the audio player visible."""
24
+ music_path = random.choice(music_files)
25
  return music_path, gr.update(visible=True)
26
 
27
+
28
  # Main function to generate a cocktail recipe based on user preferences
29
  def generate_cocktail(mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests):
30
  """Generates a cocktail recipe using OpenAI's GPT-4 based on user input."""
 
152
  demo.launch(#enable_queue=False,
153
  # Creates an auth screen
154
  auth_message="Welcome! Enter a Username and Password"
155
+ ).queue()