Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
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.
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|