Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -318,7 +318,15 @@ def navigate_lines(button):
|
|
318 |
line_index = min(line_index + 1, len(lines) - 1)
|
319 |
elif button == 'previous':
|
320 |
line_index = max(line_index - 1, 0)
|
321 |
-
return lines[line_index].strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
|
323 |
# Gradio interface function
|
324 |
def audio_capture_interface():
|
@@ -331,18 +339,10 @@ def audio_capture_interface():
|
|
331 |
with gr.Row():
|
332 |
status_output = gr.Textbox(label="Status", placeholder="Status will appear here")
|
333 |
with gr.Row():
|
334 |
-
gr.Button("Previous").click(lambda: navigate_lines('previous'),
|
335 |
-
gr.Button("Forward").click(lambda: navigate_lines('forward'),
|
336 |
gr.Button("Submit").click(process_audio, inputs=audio_input, outputs=status_output)
|
337 |
|
338 |
-
# Handle file upload
|
339 |
-
def upload_file(file):
|
340 |
-
if file:
|
341 |
-
file_path = file.name
|
342 |
-
text_display.update(read_lines_from_file(file_path))
|
343 |
-
else:
|
344 |
-
text_display.update("No file uploaded.")
|
345 |
-
|
346 |
file_upload.upload(upload_file, outputs=text_display)
|
347 |
|
348 |
return iface
|
@@ -350,4 +350,3 @@ def audio_capture_interface():
|
|
350 |
# Launch the interface
|
351 |
iface = audio_capture_interface()
|
352 |
iface.launch()
|
353 |
-
|
|
|
318 |
line_index = min(line_index + 1, len(lines) - 1)
|
319 |
elif button == 'previous':
|
320 |
line_index = max(line_index - 1, 0)
|
321 |
+
return lines[line_index].strip() if lines else "No lines found."
|
322 |
+
|
323 |
+
# Function to handle file upload
|
324 |
+
def upload_file(file):
|
325 |
+
if file is not None:
|
326 |
+
file_path = file.name
|
327 |
+
return read_lines_from_file(file_path)
|
328 |
+
else:
|
329 |
+
return "No file uploaded."
|
330 |
|
331 |
# Gradio interface function
|
332 |
def audio_capture_interface():
|
|
|
339 |
with gr.Row():
|
340 |
status_output = gr.Textbox(label="Status", placeholder="Status will appear here")
|
341 |
with gr.Row():
|
342 |
+
gr.Button("Previous").click(lambda: navigate_lines('previous'), None, text_display)
|
343 |
+
gr.Button("Forward").click(lambda: navigate_lines('forward'), None, text_display)
|
344 |
gr.Button("Submit").click(process_audio, inputs=audio_input, outputs=status_output)
|
345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
file_upload.upload(upload_file, outputs=text_display)
|
347 |
|
348 |
return iface
|
|
|
350 |
# Launch the interface
|
351 |
iface = audio_capture_interface()
|
352 |
iface.launch()
|
|