Sajjo commited on
Commit
d1d3620
·
verified ·
1 Parent(s): 45ee4ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -22
app.py CHANGED
@@ -45,7 +45,7 @@ def save_audio_text(audio, text):
45
  if not os.path.exists("/tmp/recordings"):
46
  os.makedirs("/tmp/recordings")
47
 
48
- # Debugging to print out the structure of the audio variable
49
  print("Received audio data:", audio)
50
 
51
  try:
@@ -71,24 +71,9 @@ def save_audio_text(audio, text):
71
  return "Error saving audio."
72
 
73
  # Define the Gradio interface
74
- with gr.Blocks() as demo:
75
- with gr.Row():
76
- file_upload = gr.File(label="Upload a text file", type="binary")
77
- generate_button = gr.Button("Generate Lines")
78
-
79
- current_line = gr.Textbox(label="Current Line")
80
-
81
- def update_output(file):
82
- lines = reader.read_lines(file)
83
- save_text_lines(file) # Save the text lines to a file
84
- return lines
85
-
86
- generate_button.click(fn=update_output, inputs=file_upload, outputs=current_line)
87
-
88
- with gr.Row():
89
- audio_record = gr.Audio(sources=["microphone","upload"], type="filepath")
90
- save_button = gr.Button("Save Audio and Next Line")
91
-
92
- save_button.click(fn=save_audio_text, inputs=[audio_record, current_line], outputs=current_line)
93
-
94
- demo.launch()
 
45
  if not os.path.exists("/tmp/recordings"):
46
  os.makedirs("/tmp/recordings")
47
 
48
+ # Print out the structure of the audio variable for debugging
49
  print("Received audio data:", audio)
50
 
51
  try:
 
71
  return "Error saving audio."
72
 
73
  # Define the Gradio interface
74
+ with gr.Interface(
75
+ fn=save_audio_text,
76
+ inputs=[gr.Audio(source="microphone", type="file", label="Record Audio"), gr.Textbox(label="Current Line")],
77
+ outputs=gr.Textbox(label="Next Line")
78
+ ) as iface:
79
+ iface.launch()