concauu commited on
Commit
9b2c073
·
verified ·
1 Parent(s): fe376fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -104,10 +104,9 @@ def transcribe_speech(audio_file):
104
  audio = r.record(source)
105
  return r.recognize_google(audio)
106
 
107
- def update_font(size):
108
  sizes = {"Small": "12px", "Medium": "16px", "Large": "20px"}
109
- # Inject a style to set base font size (affects entire app)
110
- return f"<style>.gradio-container {{ font-size: {sizes[size]} !important; }}</style>"
111
 
112
  @spaces.GPU(duration=75)
113
  def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
@@ -180,9 +179,23 @@ with gr.Blocks(css="""
180
  .bot-msg { background: #f5f5f5; border-radius: 15px; padding: 10px; margin: 5px; }
181
  """) as demo:
182
  # Global controls: font size and voice input
183
- font_choice = gr.Dropdown(choices=["Small", "Medium", "Large"], value="Medium", label="Font Size")
 
 
 
 
184
  font_style = gr.HTML() # This will receive the injected CSS for font size
185
- font_choice.change(fn=update_font, inputs=font_choice, outputs=font_style)
 
 
 
 
 
 
 
 
 
 
186
 
187
  gr.Markdown("## Voice Input: Record your prompt")
188
  audio_input = gr.Audio(sources="microphone", type="filepath", label="Record your voice")
 
104
  audio = r.record(source)
105
  return r.recognize_google(audio)
106
 
107
+ def get_font_size(size):
108
  sizes = {"Small": "12px", "Medium": "16px", "Large": "20px"}
109
+ return sizes[size]
 
110
 
111
  @spaces.GPU(duration=75)
112
  def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
 
179
  .bot-msg { background: #f5f5f5; border-radius: 15px; padding: 10px; margin: 5px; }
180
  """) as demo:
181
  # Global controls: font size and voice input
182
+ font_choice = gr.Dropdown(
183
+ choices=["Small", "Medium", "Large"],
184
+ value="Medium",
185
+ label="Font Size"
186
+ )
187
  font_style = gr.HTML() # This will receive the injected CSS for font size
188
+ font_choice.change(
189
+ fn=get_font_size,
190
+ inputs=font_choice,
191
+ outputs=[], # no output component needed
192
+ _js="""
193
+ (fontSize) => {
194
+ document.body.style.fontSize = fontSize;
195
+ return "";
196
+ }
197
+ """
198
+ )
199
 
200
  gr.Markdown("## Voice Input: Record your prompt")
201
  audio_input = gr.Audio(sources="microphone", type="filepath", label="Record your voice")