Sajjo commited on
Commit
3d84af1
·
verified ·
1 Parent(s): 17479cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
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
- # Print out the structure of the audio variable for debugging
49
  print("Received audio data:", audio)
50
 
51
  try:
@@ -71,10 +71,24 @@ def save_audio_text(audio, text):
71
  return "Error saving audio."
72
 
73
  # Define the Gradio interface
74
- with gr.Interface(
75
- fn=save_audio_text,
76
- inputs=[gr.Audio(sources=["microphone","upload"], type="filepath"),
77
- gr.Textbox(label="Current Line")],
78
- outputs=gr.Textbox(label="Next Line")
79
- ) as iface:
80
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  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()