Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
ZennyKenny
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -71,7 +71,10 @@ def main():
|
|
71 |
def process_audio(audio_input):
|
72 |
try:
|
73 |
# Debug input type and content
|
74 |
-
print(f"Input type: {type(audio_input)}")
|
|
|
|
|
|
|
75 |
if isinstance(audio_input, tuple): # Recorded audio
|
76 |
print("Handling recorded audio.")
|
77 |
audio_data, sr = audio_input
|
@@ -98,12 +101,18 @@ def main():
|
|
98 |
print(f"Error in process_audio: {e}")
|
99 |
return f"Error processing audio: {e}", "", ""
|
100 |
|
|
|
|
|
|
|
|
|
|
|
101 |
with gr.Blocks() as interface:
|
102 |
with gr.Row():
|
103 |
with gr.Column():
|
104 |
# Enable recording or file upload
|
105 |
audio_input = gr.Audio(type="numpy", label="Record or Upload Audio")
|
106 |
process_button = gr.Button("Process Audio")
|
|
|
107 |
with gr.Column():
|
108 |
transcription_output = gr.Textbox(label="Full Transcription", lines=10)
|
109 |
summary_output = gr.Textbox(label="Summary", lines=5)
|
@@ -115,7 +124,13 @@ def main():
|
|
115 |
outputs=[transcription_output, summary_output, audio_output]
|
116 |
)
|
117 |
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
if __name__ == "__main__":
|
121 |
main()
|
|
|
71 |
def process_audio(audio_input):
|
72 |
try:
|
73 |
# Debug input type and content
|
74 |
+
print(f"Input type: {type(audio_input)}, Input: {audio_input}")
|
75 |
+
if audio_input is None:
|
76 |
+
raise ValueError("No audio input received. Please record or upload an audio file.")
|
77 |
+
|
78 |
if isinstance(audio_input, tuple): # Recorded audio
|
79 |
print("Handling recorded audio.")
|
80 |
audio_data, sr = audio_input
|
|
|
101 |
print(f"Error in process_audio: {e}")
|
102 |
return f"Error processing audio: {e}", "", ""
|
103 |
|
104 |
+
def stop_microphone():
|
105 |
+
"""Simulate stopping the microphone."""
|
106 |
+
print("Microphone stopped.")
|
107 |
+
return "Microphone stopped. Recording session has ended."
|
108 |
+
|
109 |
with gr.Blocks() as interface:
|
110 |
with gr.Row():
|
111 |
with gr.Column():
|
112 |
# Enable recording or file upload
|
113 |
audio_input = gr.Audio(type="numpy", label="Record or Upload Audio")
|
114 |
process_button = gr.Button("Process Audio")
|
115 |
+
stop_button = gr.Button("Stop Recording")
|
116 |
with gr.Column():
|
117 |
transcription_output = gr.Textbox(label="Full Transcription", lines=10)
|
118 |
summary_output = gr.Textbox(label="Summary", lines=5)
|
|
|
124 |
outputs=[transcription_output, summary_output, audio_output]
|
125 |
)
|
126 |
|
127 |
+
stop_button.click(
|
128 |
+
stop_microphone,
|
129 |
+
inputs=[],
|
130 |
+
outputs=[]
|
131 |
+
)
|
132 |
+
|
133 |
+
interface.launch(share=False)
|
134 |
|
135 |
if __name__ == "__main__":
|
136 |
main()
|