Spaces:
Runtime error
Runtime error
Georgi Petrov
commited on
Commit
·
64552b4
1
Parent(s):
c623ccd
WIP
Browse files- app.py +35 -43
- app2.py +1 -1
- arxiv_helper.py +162 -0
- generate_qa.py +1 -1
- parser.py → parser2.py +0 -0
app.py
CHANGED
|
@@ -1,49 +1,41 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from tts import speak
|
| 3 |
-
from
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def process(
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
if input_audio:
|
| 15 |
-
voice_text = convert_voice_to_text(input_audio)
|
| 16 |
-
command = convert_voice_text_to_command(voice_text)
|
| 17 |
-
else:
|
| 18 |
-
voice_text = ""
|
| 19 |
-
command = ""
|
| 20 |
-
|
| 21 |
-
return (gr.Audio(value=audio_stream, format="wav", autoplay=True, visible=False),
|
| 22 |
-
file_path,
|
| 23 |
-
voice_text,
|
| 24 |
-
command
|
| 25 |
)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from tts import speak
|
| 3 |
+
from arxiv_helper import arxiv_categories
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def process(categories: gr.Dropdown,
|
| 7 |
+
subcategories: gr.Dropdown):
|
| 8 |
+
|
| 9 |
+
conversaion_text = "The conversation goes here"
|
| 10 |
+
|
| 11 |
+
return (gr.Audio(value=None, format="wav", autoplay=True, visible=False),
|
| 12 |
+
conversaion_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
+
def update_subcategory_dropdown(selection):
|
| 16 |
+
return gr.update(choices=list(arxiv_categories[selection].values()))
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
with gr.Blocks() as demo:
|
| 20 |
+
category_dropdown = gr.Dropdown(label="arXiv Category", choices=list(arxiv_categories.keys()))
|
| 21 |
+
subcategory_dropdown = gr.Dropdown(label="arXiv Subcategory", choices=[])
|
| 22 |
+
category_dropdown.change(fn=update_subcategory_dropdown, inputs=category_dropdown, outputs=subcategory_dropdown)
|
| 23 |
+
|
| 24 |
+
demo_interface = gr.Interface(
|
| 25 |
+
fn=process,
|
| 26 |
+
inputs=[
|
| 27 |
+
category_dropdown,
|
| 28 |
+
subcategory_dropdown,
|
| 29 |
+
],
|
| 30 |
+
outputs=[
|
| 31 |
+
gr.Audio(visible=False),
|
| 32 |
+
gr.Textbox(label="Conversation", lines=20),
|
| 33 |
+
],
|
| 34 |
+
title="Paper Whisperer",
|
| 35 |
+
description='Select arXiv papers(s) to convert into an engaging conversation!',
|
| 36 |
+
article="Paper Whisperer",
|
| 37 |
+
analytics_enabled=False,
|
| 38 |
+
allow_flagging='never'
|
| 39 |
+
)
|
| 40 |
|
| 41 |
demo.launch()
|
app2.py
CHANGED
|
@@ -3,7 +3,7 @@ from tts import speak
|
|
| 3 |
from voice_input import convert_voice_to_text, convert_voice_text_to_command
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
import time
|
| 6 |
-
from
|
| 7 |
get_paper_by_id,
|
| 8 |
parse_pdf,
|
| 9 |
parse_xml,
|
|
|
|
| 3 |
from voice_input import convert_voice_to_text, convert_voice_text_to_command
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
import time
|
| 6 |
+
from parser2 import (
|
| 7 |
get_paper_by_id,
|
|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
|
|
|
|
|
|
|
|
|
| 1 |
+
arxiv_categories = {
|
| 2 |
+
"Physics": {
|
| 3 |
+
"astro-ph.GA": "Astrophysics of Galaxies",
|
| 4 |
+
"astro-ph.CO": "Cosmology and Nongalactic Astrophysics",
|
| 5 |
+
"astro-ph.EP": "Earth and Planetary Astrophysics",
|
| 6 |
+
"astro-ph.HE": "High Energy Astrophysical Phenomena",
|
| 7 |
+
"astro-ph.IM": "Instrumentation and Methods for Astrophysics",
|
| 8 |
+
"astro-ph.SR": "Solar and Stellar Astrophysics",
|
| 9 |
+
"cond-mat.dis-nn": "Disordered Systems and Neural Networks",
|
| 10 |
+
"cond-mat.mtrl-sci": "Materials Science",
|
| 11 |
+
"cond-mat.mes-hall": "Mesoscale and Nanoscale Physics",
|
| 12 |
+
"cond-mat.other": "Other Condensed Matter",
|
| 13 |
+
"cond-mat.quant-gas": "Quantum Gases",
|
| 14 |
+
"cond-mat.soft": "Soft Condensed Matter",
|
| 15 |
+
"cond-mat.stat-mech": "Statistical Mechanics",
|
| 16 |
+
"cond-mat.str-el": "Strongly Correlated Electrons",
|
| 17 |
+
"cond-mat.supr-con": "Superconductivity",
|
| 18 |
+
"gr-qc": "General Relativity and Quantum Cosmology",
|
| 19 |
+
"hep-ex": "High Energy Physics - Experiment",
|
| 20 |
+
"hep-lat": "High Energy Physics - Lattice",
|
| 21 |
+
"hep-ph": "High Energy Physics - Phenomenology",
|
| 22 |
+
"hep-th": "High Energy Physics - Theory",
|
| 23 |
+
"math-ph": "Mathematical Physics",
|
| 24 |
+
"nlin.AO": "Adaptation and Self-Organizing Systems",
|
| 25 |
+
"nlin.CG": "Cellular Automata and Lattice Gases",
|
| 26 |
+
"nlin.CD": "Chaotic Dynamics",
|
| 27 |
+
"nlin.SI": "Exactly Solvable and Integrable Systems",
|
| 28 |
+
"nlin.PS": "Pattern Formation and Solitons",
|
| 29 |
+
"nucl-ex": "Nuclear Experiment",
|
| 30 |
+
"nucl-th": "Nuclear Theory",
|
| 31 |
+
"physics.acc-ph": "Accelerator Physics",
|
| 32 |
+
"physics.app-ph": "Applied Physics",
|
| 33 |
+
"physics.ao-ph": "Atmospheric and Oceanic Physics",
|
| 34 |
+
"physics.atom-ph": "Atomic Physics",
|
| 35 |
+
"physics.atm-clus": "Atomic and Molecular Clusters",
|
| 36 |
+
"physics.bio-ph": "Biological Physics",
|
| 37 |
+
"physics.chem-ph": "Chemical Physics",
|
| 38 |
+
"physics.class-ph": "Classical Physics",
|
| 39 |
+
"physics.comp-ph": "Computational Physics",
|
| 40 |
+
"physics.data-an": "Data Analysis, Statistics and Probability",
|
| 41 |
+
"physics.flu-dyn": "Fluid Dynamics",
|
| 42 |
+
"physics.gen-ph": "General Physics",
|
| 43 |
+
"physics.geo-ph": "Geophysics",
|
| 44 |
+
"physics.hist-ph": "History and Philosophy of Physics",
|
| 45 |
+
"physics.ins-det": "Instrumentation and Detectors",
|
| 46 |
+
"physics.med-ph": "Medical Physics",
|
| 47 |
+
"physics.optics": "Optics",
|
| 48 |
+
"physics.ed-ph": "Physics Education",
|
| 49 |
+
"physics.soc-ph": "Physics and Society",
|
| 50 |
+
"physics.plasm-ph": "Plasma Physics",
|
| 51 |
+
"physics.pop-ph": "Popular Physics",
|
| 52 |
+
"physics.space-ph": "Space Physics",
|
| 53 |
+
"quant-ph": "Quantum Physics",
|
| 54 |
+
},
|
| 55 |
+
"Mathematics": {
|
| 56 |
+
"math.AG": "Algebraic Geometry",
|
| 57 |
+
"math.AT": "Algebraic Topology",
|
| 58 |
+
"math.AP": "Analysis of PDEs",
|
| 59 |
+
"math.CT": "Category Theory",
|
| 60 |
+
"math.CA": "Classical Analysis and ODEs",
|
| 61 |
+
"math.CO": "Combinatorics",
|
| 62 |
+
"math.AC": "Commutative Algebra",
|
| 63 |
+
"math.CV": "Complex Variables",
|
| 64 |
+
"math.DG": "Differential Geometry",
|
| 65 |
+
"math.DS": "Dynamical Systems",
|
| 66 |
+
"math.FA": "Functional Analysis",
|
| 67 |
+
"math.GM": "General Mathematics",
|
| 68 |
+
"math.GN": "General Topology",
|
| 69 |
+
"math.GT": "Geometric Topology",
|
| 70 |
+
"math.GR": "Group Theory",
|
| 71 |
+
"math.HO": "History and Overview",
|
| 72 |
+
"math.IT": "Information Theory",
|
| 73 |
+
"math.KT": "K-Theory and Homology",
|
| 74 |
+
"math.LO": "Logic",
|
| 75 |
+
"math.MP": "Mathematical Physics",
|
| 76 |
+
"math.MG": "Metric Geometry",
|
| 77 |
+
"math.NT": "Number Theory",
|
| 78 |
+
"math.NA": "Numerical Analysis",
|
| 79 |
+
"math.OA": "Operator Algebras",
|
| 80 |
+
"math.OC": "Optimization and Control",
|
| 81 |
+
"math.PR": "Probability",
|
| 82 |
+
"math.QA": "Quantum Algebra",
|
| 83 |
+
"math.RT": "Representation Theory",
|
| 84 |
+
"math.RA": "Rings and Algebras",
|
| 85 |
+
"math.SP": "Spectral Theory",
|
| 86 |
+
"math.ST": "Statistics Theory",
|
| 87 |
+
"math.SG": "Symplectic Geometry",
|
| 88 |
+
},
|
| 89 |
+
"Computer Science": {
|
| 90 |
+
"cs.AI": "Artificial Intelligence",
|
| 91 |
+
"cs.CL": "Computation and Language",
|
| 92 |
+
"cs.CC": "Computational Complexity",
|
| 93 |
+
"cs.CE": "Computational Engineering, Finance, and Science",
|
| 94 |
+
"cs.CG": "Computational Geometry",
|
| 95 |
+
"cs.GT": "Computer Science and Game Theory",
|
| 96 |
+
"cs.CV": "Computer Vision and Pattern Recognition",
|
| 97 |
+
"cs.CY": "Computers and Society",
|
| 98 |
+
"cs.CR": "Cryptography and Security",
|
| 99 |
+
"cs.DS": "Data Structures and Algorithms",
|
| 100 |
+
"cs.DB": "Databases",
|
| 101 |
+
"cs.DL": "Digital Libraries",
|
| 102 |
+
"cs.DM": "Discrete Mathematics",
|
| 103 |
+
"cs.DC": "Distributed, Parallel, and Cluster Computing",
|
| 104 |
+
"cs.ET": "Emerging Technologies",
|
| 105 |
+
"cs.FL": "Formal Languages and Automata Theory",
|
| 106 |
+
"cs.GL": "General Literature",
|
| 107 |
+
"cs.GR": "Graphics",
|
| 108 |
+
"cs.AR": "Hardware Architecture",
|
| 109 |
+
"cs.HC": "Human-Computer Interaction",
|
| 110 |
+
"cs.IR": "Information Retrieval",
|
| 111 |
+
"cs.IT": "Information Theory",
|
| 112 |
+
"cs.LG": "Learning",
|
| 113 |
+
"cs.LO": "Logic in Computer Science",
|
| 114 |
+
"cs.MS": "Mathematical Software",
|
| 115 |
+
"cs.MA": "Multiagent Systems",
|
| 116 |
+
"cs.MM": "Multimedia",
|
| 117 |
+
"cs.NI": "Networking and Internet Architecture",
|
| 118 |
+
"cs.NE": "Neural and Evolutionary Computing",
|
| 119 |
+
"cs.NA": "Numerical Analysis",
|
| 120 |
+
"cs.OS": "Operating Systems",
|
| 121 |
+
"cs.OH": "Other Computer Science",
|
| 122 |
+
"cs.PF": "Performance",
|
| 123 |
+
"cs.PL": "Programming Languages",
|
| 124 |
+
"cs.RO": "Robotics",
|
| 125 |
+
"cs.SI": "Social and Information Networks",
|
| 126 |
+
"cs.SE": "Software Engineering",
|
| 127 |
+
"cs.SD": "Sound",
|
| 128 |
+
"cs.SC": "Symbolic Computation",
|
| 129 |
+
"cs.SY": "Systems and Control",
|
| 130 |
+
},
|
| 131 |
+
"Quantitative Biology": {
|
| 132 |
+
"q-bio.BM": "Biomolecules",
|
| 133 |
+
"q-bio.GN": "Genomics",
|
| 134 |
+
"q-bio.MN": "Molecular Networks",
|
| 135 |
+
"q-bio.SC": "Subcellular Processes",
|
| 136 |
+
"q-bio.CB": "Cell Behavior",
|
| 137 |
+
"q-bio.NC": "Neurons and Cognition",
|
| 138 |
+
"q-bio.TO": "Tissues and Organs",
|
| 139 |
+
"q-bio.PE": "Populations and Evolution",
|
| 140 |
+
"q-bio.QM": "Quantitative Methods",
|
| 141 |
+
"q-bio.OT": "Other",
|
| 142 |
+
},
|
| 143 |
+
"Quantitative Finance": {
|
| 144 |
+
"q-fin.PR": "Pricing of Securities",
|
| 145 |
+
"q-fin.RM": "Risk Management",
|
| 146 |
+
"q-fin.PM": "Portfolio Management",
|
| 147 |
+
"q-fin.TR": "Trading and Microstructure",
|
| 148 |
+
"q-fin.MF": "Mathematical Finance",
|
| 149 |
+
"q-fin.CP": "Computational Finance",
|
| 150 |
+
"q-fin.ST": "Statistical Finance",
|
| 151 |
+
"q-fin.GN": "General Finance",
|
| 152 |
+
"q-fin.EC": "Economics",
|
| 153 |
+
},
|
| 154 |
+
"Statistics": {
|
| 155 |
+
"stat.AP": "Applications",
|
| 156 |
+
"stat.CO": "Computation",
|
| 157 |
+
"stat.ML": "Machine Learning",
|
| 158 |
+
"stat.ME": "Methodology",
|
| 159 |
+
"stat.OT": "Other Statistics",
|
| 160 |
+
"stat.TH": "Theory",
|
| 161 |
+
}
|
| 162 |
+
}
|
generate_qa.py
CHANGED
|
@@ -71,7 +71,7 @@ def process_qa_chain(sections_dict: OrderedDict):
|
|
| 71 |
|
| 72 |
if __name__ == '__main__':
|
| 73 |
from bs4 import BeautifulSoup
|
| 74 |
-
from
|
| 75 |
get_paper_by_id,
|
| 76 |
parse_pdf,
|
| 77 |
parse_xml,
|
|
|
|
| 71 |
|
| 72 |
if __name__ == '__main__':
|
| 73 |
from bs4 import BeautifulSoup
|
| 74 |
+
from parser2 import (
|
| 75 |
get_paper_by_id,
|
| 76 |
parse_pdf,
|
| 77 |
parse_xml,
|
parser.py → parser2.py
RENAMED
|
File without changes
|