bai4578 commited on
Commit
7876967
·
verified ·
1 Parent(s): 63d238c

Update app.py

Browse files

first disappaer attempt

Files changed (1) hide show
  1. app.py +27 -21
app.py CHANGED
@@ -336,32 +336,39 @@ with gr.Blocks(title="Audio Recorder, Transcriber, and Text Generator") as demo:
336
  login_button = gr.Button("Login")
337
  login_message = gr.Markdown()
338
 
 
 
 
 
 
 
339
  with gr.Column(visible=False) as main_interface:
340
  gr.Markdown("Record audio, transcribe it, or enter text manually, and optionally generate text based on the input.")
341
 
342
  input_toggle = gr.Checkbox(label="Use Manual Text Input Instead of Audio", value=False)
343
 
344
- audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Record or Upload Audio", visible=True)
 
 
 
 
 
 
 
 
 
 
345
  text_input = gr.Textbox(label="Enter Text Manually", visible=False)
346
 
 
347
  input_toggle.change(
348
  lambda use_text: (gr.update(visible=not use_text), gr.update(visible=use_text)),
349
  inputs=[input_toggle],
350
- outputs=[audio_input, text_input]
351
  )
352
 
353
- with gr.Row():
354
- save_btn = gr.Button("Save Audio")
355
- transcribe_btn = gr.Button("Transcribe Audio")
356
- transcribe_fix_btn = gr.Button("Transcribe & Fix")
357
- save_transcribe_fix_btn = gr.Button("Save, Transcribe & Fix")
358
-
359
- with gr.Row():
360
- audio_output = gr.Audio(label="Saved Audio (MP3)", format="mp3")
361
- save_msg = gr.Textbox(label="Save Status")
362
-
363
  transcription_output = gr.Textbox(label="Transcription", show_copy_button=True)
364
-
365
  with gr.Row():
366
  prompt_type = gr.Dropdown(
367
  choices=list(contentt.keys()), # Get dictionary keys as choices
@@ -369,7 +376,7 @@ with gr.Blocks(title="Audio Recorder, Transcriber, and Text Generator") as demo:
369
  value=list(contentt.keys())[0] # Default to the first key
370
  )
371
  generate_btn = gr.Button("Generate Text")
372
-
373
  generated_text_output = gr.Textbox(label="Generated Text", show_copy_button=True)
374
 
375
  # Actions for audio-related inputs
@@ -415,20 +422,19 @@ with gr.Blocks(title="Audio Recorder, Transcriber, and Text Generator") as demo:
415
  def login(password):
416
  if check_password(password):
417
  return {
418
- main_interface: gr.Column(visible=True),
419
- login_message: gr.Markdown("Login successful. You can now use the application.")
 
420
  }
421
  else:
422
  return {
423
- main_interface: gr.Column(visible=False),
424
- login_message: gr.Markdown("Incorrect password. Please try again.")
425
  }
426
 
427
  login_button.click(
428
  login,
429
  inputs=[password_input],
430
- outputs=[main_interface, login_message]
431
  )
432
 
433
- demo.launch()
434
-
 
336
  login_button = gr.Button("Login")
337
  login_message = gr.Markdown()
338
 
339
+ # Wrap login UI in a container to hide it after login
340
+ with gr.Column() as login_container:
341
+ password_input.render()
342
+ login_button.render()
343
+ login_message.render()
344
+
345
  with gr.Column(visible=False) as main_interface:
346
  gr.Markdown("Record audio, transcribe it, or enter text manually, and optionally generate text based on the input.")
347
 
348
  input_toggle = gr.Checkbox(label="Use Manual Text Input Instead of Audio", value=False)
349
 
350
+ with gr.Column() as audio_section:
351
+ audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Record or Upload Audio")
352
+ with gr.Row():
353
+ save_btn = gr.Button("Save Audio")
354
+ transcribe_btn = gr.Button("Transcribe Audio")
355
+ transcribe_fix_btn = gr.Button("Transcribe & Fix")
356
+ save_transcribe_fix_btn = gr.Button("Save, Transcribe & Fix")
357
+ with gr.Row():
358
+ audio_output = gr.Audio(label="Saved Audio (MP3)", format="mp3")
359
+ save_msg = gr.Textbox(label="Save Status")
360
+
361
  text_input = gr.Textbox(label="Enter Text Manually", visible=False)
362
 
363
+ # Hide audio section when manual input is selected
364
  input_toggle.change(
365
  lambda use_text: (gr.update(visible=not use_text), gr.update(visible=use_text)),
366
  inputs=[input_toggle],
367
+ outputs=[audio_section, text_input]
368
  )
369
 
 
 
 
 
 
 
 
 
 
 
370
  transcription_output = gr.Textbox(label="Transcription", show_copy_button=True)
371
+
372
  with gr.Row():
373
  prompt_type = gr.Dropdown(
374
  choices=list(contentt.keys()), # Get dictionary keys as choices
 
376
  value=list(contentt.keys())[0] # Default to the first key
377
  )
378
  generate_btn = gr.Button("Generate Text")
379
+
380
  generated_text_output = gr.Textbox(label="Generated Text", show_copy_button=True)
381
 
382
  # Actions for audio-related inputs
 
422
  def login(password):
423
  if check_password(password):
424
  return {
425
+ login_container: gr.update(visible=False), # Hide login UI
426
+ main_interface: gr.update(visible=True), # Show main interface
427
+ login_message: gr.update(value="Login successful.", visible=True)
428
  }
429
  else:
430
  return {
431
+ login_message: gr.update(value="Incorrect password. Please try again.", visible=True)
 
432
  }
433
 
434
  login_button.click(
435
  login,
436
  inputs=[password_input],
437
+ outputs=[login_container, main_interface, login_message]
438
  )
439
 
440
+ demo.launch()