Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from transformers import pipeline
|
|
4 |
import pandas as pd
|
5 |
import os
|
6 |
|
|
|
7 |
aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
|
8 |
|
9 |
# Initialize question answering pipeline
|
@@ -117,13 +118,23 @@ def main(audio):
|
|
117 |
|
118 |
# Add a title to the DataFrame
|
119 |
df['Question'] = oral_health_assessment_form
|
|
|
|
|
|
|
120 |
|
121 |
-
return
|
122 |
|
123 |
-
# Function to handle
|
124 |
-
def
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
return "Data submitted successfully!"
|
128 |
|
129 |
# Create the Gradio interface
|
@@ -132,13 +143,13 @@ with gr.Blocks() as demo:
|
|
132 |
with gr.Row():
|
133 |
with gr.Column():
|
134 |
audio_input = gr.Audio(type="filepath", label="Record your audio")
|
135 |
-
|
136 |
-
submit_button = gr.Button("Submit")
|
137 |
with gr.Column():
|
138 |
transcribe_button = gr.Button("Transcribe and Generate Form")
|
|
|
139 |
|
140 |
-
transcribe_button.click(fn=main, inputs=audio_input, outputs=
|
141 |
-
submit_button.click(fn=
|
142 |
|
143 |
# Launch the app
|
144 |
demo.launch()
|
|
|
4 |
import pandas as pd
|
5 |
import os
|
6 |
|
7 |
+
# Replace with your AssemblyAI API key
|
8 |
aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
|
9 |
|
10 |
# Initialize question answering pipeline
|
|
|
118 |
|
119 |
# Add a title to the DataFrame
|
120 |
df['Question'] = oral_health_assessment_form
|
121 |
+
|
122 |
+
# Convert DataFrame to HTML table with editable text boxes
|
123 |
+
table_html = df.to_html(index=False, escape=False, formatters={"Answer": lambda x: f'<input type="text" value="{x}" />'})
|
124 |
|
125 |
+
return table_html
|
126 |
|
127 |
+
# Function to handle submit button and store table data in dictionary
|
128 |
+
def submit_table_data(html_table):
|
129 |
+
# Extract input values from HTML table
|
130 |
+
tabledata = {}
|
131 |
+
for line in html_table.split('\n'):
|
132 |
+
if '<td>' in line:
|
133 |
+
question = line.split('<td>')[1].split('</td>')[0]
|
134 |
+
answer = line.split('value="')[1].split('"')[0]
|
135 |
+
tabledata[question] = answer
|
136 |
+
|
137 |
+
print("Submitted Table Data: ", tabledata)
|
138 |
return "Data submitted successfully!"
|
139 |
|
140 |
# Create the Gradio interface
|
|
|
143 |
with gr.Row():
|
144 |
with gr.Column():
|
145 |
audio_input = gr.Audio(type="filepath", label="Record your audio")
|
146 |
+
output_html = gr.HTML(label="Assessment Form")
|
|
|
147 |
with gr.Column():
|
148 |
transcribe_button = gr.Button("Transcribe and Generate Form")
|
149 |
+
submit_button = gr.Button("Submit")
|
150 |
|
151 |
+
transcribe_button.click(fn=main, inputs=audio_input, outputs=output_html)
|
152 |
+
submit_button.click(fn=submit_table_data, inputs=output_html, outputs="text")
|
153 |
|
154 |
# Launch the app
|
155 |
demo.launch()
|