lilyhof commited on
Commit
c779966
1 Parent(s): d40b89b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -94,22 +94,26 @@ def gradio_mic_interface(mic_input):
94
  # Initialize Blocks
95
  demo = gr.Blocks()
96
 
97
- # Define the interfaces inside the Blocks context
98
- with demo:
99
- mic_transcribe = gr.Interface(
 
 
 
 
 
 
100
  fn=gradio_mic_interface,
101
- inputs=gr.Audio(type="numpy"), # Use numpy for real-time audio like microphone
102
  outputs=gr.Textbox(label="Prediction")
103
  )
104
 
105
- file_transcribe = gr.Interface(
106
- fn=gradio_file_interface,
107
- inputs=gr.Audio(type="filepath"), # Use filepath for uploaded audio files
108
- outputs=gr.Textbox(label="Prediction")
 
109
  )
110
-
111
- # Combine interfaces into a tabbed interface
112
- # gr.TabbedInterface([mic_transcribe, file_transcribe], ["Transcribe Microphone", "Transcribe Audio File"])
113
 
114
  # Launch the demo with debugging enabled
115
- demo.launch(debug=True)
 
94
  # Initialize Blocks
95
  demo = gr.Blocks()
96
 
97
+ # Tab 1: Upload File
98
+ file_interface = gr.Interface(
99
+ fn=gradio_file_interface,
100
+ inputs=gr.Audio(sources="upload", type="filepath"), # Use filepath for uploaded audio files
101
+ outputs=gr.Textbox(label="Prediction")
102
+ )
103
+
104
+ # Tab 2: Record with Mic
105
+ mic_interface = gr.Interface(
106
  fn=gradio_mic_interface,
107
+ inputs=gr.Audio(sources="microphone", type="numpy"), # Use numpy for real-time audio like microphone
108
  outputs=gr.Textbox(label="Prediction")
109
  )
110
 
111
+ # Define the interfaces inside the Blocks context
112
+ with demo:
113
+ gr.TabbedInterface(
114
+ [file_interface, mic_interface],
115
+ ["Upload File", "Record Using Microphone"]
116
  )
 
 
 
117
 
118
  # Launch the demo with debugging enabled
119
+ demo.launch(debug=True)