Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,30 +25,6 @@ def load_jsonl(file_path):
|
|
25 |
def filter_by_keyword(df, keyword):
|
26 |
return df[df.apply(lambda row: row.astype(str).str.contains(keyword).any(), axis=1)]
|
27 |
|
28 |
-
# Function to generate HTML5 code with embedded text
|
29 |
-
def generate_html(question_text, answer_text, idx):
|
30 |
-
return f'''
|
31 |
-
<!DOCTYPE html>
|
32 |
-
<html>
|
33 |
-
<head>
|
34 |
-
<title>Read It Aloud</title>
|
35 |
-
<script type="text/javascript">
|
36 |
-
function readAloud{id}() {{
|
37 |
-
const text = document.getElementById("questionArea{id}").innerText;
|
38 |
-
const speech = new SpeechSynthesisUtterance(text);
|
39 |
-
window.speechSynthesis.speak(speech);
|
40 |
-
}}
|
41 |
-
</script>
|
42 |
-
</head>
|
43 |
-
<body>
|
44 |
-
<h1>🔊 Read It Aloud - Row {idx}</h1>
|
45 |
-
<p id="questionArea{id}">{question_text}</p>
|
46 |
-
<button onclick="readAloud{id}()">🔊 Read Question Aloud</button>
|
47 |
-
</body>
|
48 |
-
</html>
|
49 |
-
'''
|
50 |
-
|
51 |
-
|
52 |
# Streamlit App
|
53 |
st.title("Medical Licensing Exam Explorer with Speech Synthesis, Plotly and Seaborn 📊")
|
54 |
|
@@ -75,6 +51,40 @@ if st.button("Search"):
|
|
75 |
st.write(f"Filtered Dataset by '{search_keyword}'")
|
76 |
selected_data = st.dataframe(filtered_data)
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
# Button to read all filtered rows
|
79 |
if st.button("Read All Rows"):
|
80 |
if not filtered_data.empty:
|
@@ -88,6 +98,13 @@ if st.button("Read All Rows"):
|
|
88 |
else:
|
89 |
st.warning("No rows to read.")
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
# Plotly and Seaborn charts for EDA
|
92 |
if st.button("Generate Charts"):
|
93 |
st.subheader("Plotly Charts 📈")
|
|
|
25 |
def filter_by_keyword(df, keyword):
|
26 |
return df[df.apply(lambda row: row.astype(str).str.contains(keyword).any(), axis=1)]
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
# Streamlit App
|
29 |
st.title("Medical Licensing Exam Explorer with Speech Synthesis, Plotly and Seaborn 📊")
|
30 |
|
|
|
51 |
st.write(f"Filtered Dataset by '{search_keyword}'")
|
52 |
selected_data = st.dataframe(filtered_data)
|
53 |
|
54 |
+
|
55 |
+
|
56 |
+
def generate_html_with_textarea(text_to_speak):
|
57 |
+
return f'''
|
58 |
+
<!DOCTYPE html>
|
59 |
+
<html>
|
60 |
+
<head>
|
61 |
+
<title>Read It Aloud</title>
|
62 |
+
<script type="text/javascript">
|
63 |
+
function readAloud() {{
|
64 |
+
const text = document.getElementById("textArea").value;
|
65 |
+
const speech = new SpeechSynthesisUtterance(text);
|
66 |
+
window.speechSynthesis.speak(speech);
|
67 |
+
}}
|
68 |
+
</script>
|
69 |
+
</head>
|
70 |
+
<body>
|
71 |
+
<h1>🔊 Read It Aloud</h1>
|
72 |
+
<textarea id="textArea" rows="10" cols="80">
|
73 |
+
{text_to_speak}
|
74 |
+
</textarea>
|
75 |
+
<br>
|
76 |
+
<button onclick="readAloud()">🔊 Read Aloud</button>
|
77 |
+
</body>
|
78 |
+
</html>
|
79 |
+
'''
|
80 |
+
|
81 |
+
# Define your text passage
|
82 |
+
text_passage = "A 60-year-old man is brought to the emergency department by police officers because he was acting strangely in public. The patient was found talking nonsensically to characters on cereal boxes in the store. Past medical history is significant for multiple hospitalizations for alcohol-related injuries and seizures. The patient’s vital signs are within normal limits. Physical examination shows a disheveled male who is oriented to person, but not time or place. Neurologic examination shows nystagmus and severe gait ataxia. A T1/T2 MRI is performed and demonstrates evidence of damage to the mammillary bodies. The patient is given the appropriate treatment for recovering most of his cognitive functions. However, significant short-term memory deficits persist. The patient remembers events from his past such as the school and college he attended, his current job, and the names of family members quite well. Which of the following is the most likely diagnosis in this patient?"
|
83 |
+
|
84 |
+
# Generate HTML code
|
85 |
+
documentHTML5 = generate_html_with_textarea(text_passage)
|
86 |
+
|
87 |
+
|
88 |
# Button to read all filtered rows
|
89 |
if st.button("Read All Rows"):
|
90 |
if not filtered_data.empty:
|
|
|
98 |
else:
|
99 |
st.warning("No rows to read.")
|
100 |
|
101 |
+
|
102 |
+
# Insert the HTML into Streamlit
|
103 |
+
# Button to read all filtered rows
|
104 |
+
if st.button("Read Aloud Text"):
|
105 |
+
components.html(documentHTML5, width=1280, height=1024)
|
106 |
+
|
107 |
+
|
108 |
# Plotly and Seaborn charts for EDA
|
109 |
if st.button("Generate Charts"):
|
110 |
st.subheader("Plotly Charts 📈")
|