awacke1 commited on
Commit
8092d9e
Β·
verified Β·
1 Parent(s): 3a0c310

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -64,7 +64,7 @@ with gr.Blocks() as demo:
64
  def audio_echo(audio):
65
  return (audio[1], 22050) # Return the audio with same sample rate
66
 
67
- gr.Interface(fn=audio_echo, inputs=gr.Audio(source="microphone", type="numpy"), outputs="audio")
68
 
69
  # 12. πŸ“‚ File - Where digital hoarders unite!
70
  def file_fun(file):
@@ -83,9 +83,9 @@ with gr.Blocks() as demo:
83
  if choice == "Image":
84
  return Image.new('RGB', (100, 100), color = 'red')
85
  elif choice == "Video":
86
- return gr.Video.update(visible=True, value="path_to_video.mp4")
87
  else:
88
- return gr.Audio.update(visible=True, value="path_to_audio.mp3")
89
 
90
  gr.Interface(
91
  fn=media_madness,
@@ -114,7 +114,6 @@ with gr.Blocks() as demo:
114
  return "Initiating launch sequence... Don't forget your space helmet!"
115
 
116
  launch_interface = gr.Interface(fn=prepare_for_launch, inputs=None, outputs="text")
117
- launch_interface.launch()
118
 
119
  # 20. πŸšͺ Close - All good things must come to an end (like this increasingly long demo)
120
  def time_to_close():
@@ -124,7 +123,9 @@ with gr.Blocks() as demo:
124
  gr.Interface(fn=time_to_close, inputs=None, outputs="text")
125
 
126
  # 21. πŸ’Ύ Load - Because sometimes you just need to pick up where you left off
127
- saved_interface = gr.Interface.load("models/saved_model")
 
 
128
 
129
  # 22. πŸ“‘ TabbedInterface - For when you can't decide which interface to use!
130
  with gr.TabbedInterface([launch_interface, saved_interface], ["New Launch", "Saved Launch"]):
@@ -162,10 +163,10 @@ with gr.Blocks() as demo:
162
  gr.Interface(fn=secret_function, inputs=None, outputs="text").launch(auth=("user", "pass"))
163
 
164
  # 27. 🎨 Theme - Because even data needs a good outfit
165
- gr.Theme.from_hub("freddyaboulton/dracula_revamped")
166
 
167
  # 28. πŸ“Š Analytics - Keeping track of all the fun (and the not-so-fun)
168
- gr.analytics_enabled = True
169
 
170
  # Let the show begin!
171
  demo.launch()
 
64
  def audio_echo(audio):
65
  return (audio[1], 22050) # Return the audio with same sample rate
66
 
67
+ gr.Interface(fn=audio_echo, inputs=gr.Audio(sources=["microphone"], type="numpy"), outputs="audio")
68
 
69
  # 12. πŸ“‚ File - Where digital hoarders unite!
70
  def file_fun(file):
 
83
  if choice == "Image":
84
  return Image.new('RGB', (100, 100), color = 'red')
85
  elif choice == "Video":
86
+ return gr.Video.update(visible=True, value=None)
87
  else:
88
+ return gr.Audio.update(visible=True, value=None)
89
 
90
  gr.Interface(
91
  fn=media_madness,
 
114
  return "Initiating launch sequence... Don't forget your space helmet!"
115
 
116
  launch_interface = gr.Interface(fn=prepare_for_launch, inputs=None, outputs="text")
 
117
 
118
  # 20. πŸšͺ Close - All good things must come to an end (like this increasingly long demo)
119
  def time_to_close():
 
123
  gr.Interface(fn=time_to_close, inputs=None, outputs="text")
124
 
125
  # 21. πŸ’Ύ Load - Because sometimes you just need to pick up where you left off
126
+ # Note: This is a placeholder. You'll need to replace it with an actual saved model.
127
+ # saved_interface = gr.Interface.load("models/saved_model")
128
+ saved_interface = gr.Interface(fn=lambda x: f"Loaded model says: {x}", inputs="text", outputs="text")
129
 
130
  # 22. πŸ“‘ TabbedInterface - For when you can't decide which interface to use!
131
  with gr.TabbedInterface([launch_interface, saved_interface], ["New Launch", "Saved Launch"]):
 
163
  gr.Interface(fn=secret_function, inputs=None, outputs="text").launch(auth=("user", "pass"))
164
 
165
  # 27. 🎨 Theme - Because even data needs a good outfit
166
+ gr.themes.Base() # Using a built-in theme as custom themes might not be available
167
 
168
  # 28. πŸ“Š Analytics - Keeping track of all the fun (and the not-so-fun)
169
+ # Note: analytics_enabled is typically set when launching the interface, not here
170
 
171
  # Let the show begin!
172
  demo.launch()