Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,6 +23,7 @@ from requests .auth import HTTPBasicAuth #line:16
|
|
23 |
import asyncio
|
24 |
import aiohttp
|
25 |
|
|
|
26 |
auth=aiohttp.BasicAuth('1234','API')
|
27 |
base_url='https://orva.tedcas.com/api/'
|
28 |
|
@@ -31,7 +32,7 @@ xlrd.xlsx.ensure_elementtree_imported(False, None)
|
|
31 |
xlrd.xlsx.Element_has_iter = True
|
32 |
|
33 |
async def buscar_faq(query, barra):
|
34 |
-
archivo = "
|
35 |
df = pd.read_excel(archivo, engine="openpyxl")
|
36 |
p = 0
|
37 |
result = query
|
@@ -708,7 +709,6 @@ async def escuchar_trauma1():
|
|
708 |
return render_template('escuchar_trauma1.html',nid2=0,prediction_text="Dale a `Escuchar´ y haz tu pregunta",user_image5=micro,user_image6=ajustes,user_image7=flecha,user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
709 |
|
710 |
@app.route("/escuchar_trauma", methods=['GET','POST'])
|
711 |
-
#@app.route("/escuchar_trauma", methods=['POST'])
|
712 |
async def escuchar_trauma():
|
713 |
#########################################################################
|
714 |
|
@@ -723,16 +723,6 @@ async def escuchar_trauma():
|
|
723 |
visualizar_videos = os.path.join(app.config['UPLOAD_FOLDER'], 'visualizar_video.png')
|
724 |
|
725 |
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
###########################################################################
|
737 |
guia_visual_ppt = os.path.join(app.config['UPLOAD_FOLDER'], 'guia_visual.png')
|
738 |
materiales = os.path.join(app.config['UPLOAD_FOLDER'], 'materiales.png')
|
@@ -746,7 +736,6 @@ async def escuchar_trauma():
|
|
746 |
|
747 |
#########################################################################################
|
748 |
r = sr.Recognizer()
|
749 |
-
#if request.method == 'POST':
|
750 |
|
751 |
recognized_text = "" # Valor predeterminado
|
752 |
|
@@ -805,7 +794,6 @@ async def escuchar_trauma():
|
|
805 |
|
806 |
else:
|
807 |
print("render2")
|
808 |
-
#return render_template('especialidad.html')
|
809 |
return render_template('buscador_trauma.html',faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha,user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales,nid2=0 )
|
810 |
#return render_template('escuchar_trauma.html',nid2=0,faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image6=ajustes,user_image7=flecha,user_image5=micro, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
811 |
else :
|
@@ -897,6 +885,20 @@ async def escuchar_admision1():
|
|
897 |
|
898 |
@app.route("/escuchar_admision", methods=['GET','POST'])
|
899 |
async def escuchar_admision():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
900 |
otros_img = os.path.join(app.config['UPLOAD_FOLDER'], 'otros_img.png')
|
901 |
programacion_img = os.path.join(app.config['UPLOAD_FOLDER'], 'programacion_img.png')
|
902 |
ambulancias_img = os.path.join(app.config['UPLOAD_FOLDER'], 'ambulancias_img.jpg')
|
@@ -905,9 +907,35 @@ async def escuchar_admision():
|
|
905 |
micro = os.path.join(app.config['UPLOAD_FOLDER'], 'micro.png')
|
906 |
ajustes = os.path.join(app.config['UPLOAD_FOLDER'], 'ajustes.png')
|
907 |
flecha = os.path.join(app.config['UPLOAD_FOLDER'], 'flecha.png')
|
908 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
query=str(query).lower()
|
910 |
query=query.split()
|
|
|
911 |
result_busqueda={}
|
912 |
result_busqueda[""]=""
|
913 |
if query[0]!="none":
|
@@ -937,7 +965,9 @@ async def escuchar_admision():
|
|
937 |
if len(output2)==0:
|
938 |
return render_template('escuchar_admision.html',user_image8=mapa_camas_img,user_image9=ambulancias_img,user_image10=programacion_img,user_image11=otros_img,result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha )
|
939 |
else:
|
940 |
-
|
|
|
|
|
941 |
else:
|
942 |
return render_template('escuchar_admision.html',user_image8=mapa_camas_img,user_image9=ambulancias_img,user_image10=programacion_img,user_image11=otros_img,prediction_text="No te he entendido bien, dale al boton `Escuchar´ y repite tu pregunta",result_busqueda=result_busqueda, user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha )
|
943 |
|
@@ -1095,6 +1125,18 @@ async def escuchar_uro1():
|
|
1095 |
|
1096 |
@app.route("/escuchar_uro", methods=['GET','POST'])
|
1097 |
async def escuchar_uro():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1098 |
guia_visual_ppt = os.path.join(app.config['UPLOAD_FOLDER'], 'guia_visual.png')
|
1099 |
materiales = os.path.join(app.config['UPLOAD_FOLDER'], 'materiales.png')
|
1100 |
pdf_casa = os.path.join(app.config['UPLOAD_FOLDER'], 'pdf_casa.jpg')
|
@@ -1103,7 +1145,31 @@ async def escuchar_uro():
|
|
1103 |
micro = os.path.join(app.config['UPLOAD_FOLDER'], 'micro.png')
|
1104 |
ajustes = os.path.join(app.config['UPLOAD_FOLDER'], 'ajustes.png')
|
1105 |
flecha = os.path.join(app.config['UPLOAD_FOLDER'], 'flecha.png')
|
1106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
query=str(query).lower()
|
1108 |
query=query.split()
|
1109 |
result_busqueda={}
|
@@ -1130,7 +1196,9 @@ async def escuchar_uro():
|
|
1130 |
if len(output2)==0:
|
1131 |
return render_template('escuchar_uro.html',nid2=0,result_busqueda=result_busqueda,user_image6=ajustes,user_image7=flecha,user_image5=micro, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
1132 |
else:
|
1133 |
-
return render_template('escuchar_uro.html',nid2=0,faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image6=ajustes,user_image7=flecha,user_image5=micro, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
|
|
|
|
1134 |
else :
|
1135 |
return render_template('escuchar_uro.html',nid2=0,result_busqueda=result_busqueda,prediction_text="No te he entendido bien, dale al boton `Escuchar´ y repite tu pregunta",user_image5=micro,user_image6=ajustes,user_image7=flecha, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
1136 |
|
|
|
23 |
import asyncio
|
24 |
import aiohttp
|
25 |
|
26 |
+
|
27 |
auth=aiohttp.BasicAuth('1234','API')
|
28 |
base_url='https://orva.tedcas.com/api/'
|
29 |
|
|
|
32 |
xlrd.xlsx.Element_has_iter = True
|
33 |
|
34 |
async def buscar_faq(query, barra):
|
35 |
+
archivo = "C:/Users/15572890/Desktop\StockPrediction\Coding\CorrelacionStocks\APIS-StockPlatforms\APIs\QuiroHelpNLP\QuirohelpWebapp/preguntas_qh_tags2.xlsx"
|
36 |
df = pd.read_excel(archivo, engine="openpyxl")
|
37 |
p = 0
|
38 |
result = query
|
|
|
709 |
return render_template('escuchar_trauma1.html',nid2=0,prediction_text="Dale a `Escuchar´ y haz tu pregunta",user_image5=micro,user_image6=ajustes,user_image7=flecha,user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
710 |
|
711 |
@app.route("/escuchar_trauma", methods=['GET','POST'])
|
|
|
712 |
async def escuchar_trauma():
|
713 |
#########################################################################
|
714 |
|
|
|
723 |
visualizar_videos = os.path.join(app.config['UPLOAD_FOLDER'], 'visualizar_video.png')
|
724 |
|
725 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
726 |
###########################################################################
|
727 |
guia_visual_ppt = os.path.join(app.config['UPLOAD_FOLDER'], 'guia_visual.png')
|
728 |
materiales = os.path.join(app.config['UPLOAD_FOLDER'], 'materiales.png')
|
|
|
736 |
|
737 |
#########################################################################################
|
738 |
r = sr.Recognizer()
|
|
|
739 |
|
740 |
recognized_text = "" # Valor predeterminado
|
741 |
|
|
|
794 |
|
795 |
else:
|
796 |
print("render2")
|
|
|
797 |
return render_template('buscador_trauma.html',faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha,user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales,nid2=0 )
|
798 |
#return render_template('escuchar_trauma.html',nid2=0,faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image6=ajustes,user_image7=flecha,user_image5=micro, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
799 |
else :
|
|
|
885 |
|
886 |
@app.route("/escuchar_admision", methods=['GET','POST'])
|
887 |
async def escuchar_admision():
|
888 |
+
#########################################################################
|
889 |
+
|
890 |
+
lupa = os.path.join(app.config['UPLOAD_FOLDER'], 'lupa.png')
|
891 |
+
micro = os.path.join(app.config['UPLOAD_FOLDER'], 'micro.png')
|
892 |
+
ajustes = os.path.join(app.config['UPLOAD_FOLDER'], 'ajustes.png')
|
893 |
+
flecha = os.path.join(app.config['UPLOAD_FOLDER'], 'flecha.png')
|
894 |
+
guia_visual_ppt = os.path.join(app.config['UPLOAD_FOLDER'], 'guia_visual.png')
|
895 |
+
materiales = os.path.join(app.config['UPLOAD_FOLDER'], 'materiales.png')
|
896 |
+
pdf_casa = os.path.join(app.config['UPLOAD_FOLDER'], 'pdf_casa.jpg')
|
897 |
+
protocolo_word = os.path.join(app.config['UPLOAD_FOLDER'], 'protocolo.jpg')
|
898 |
+
visualizar_videos = os.path.join(app.config['UPLOAD_FOLDER'], 'visualizar_video.png')
|
899 |
+
|
900 |
+
|
901 |
+
###########################################################################
|
902 |
otros_img = os.path.join(app.config['UPLOAD_FOLDER'], 'otros_img.png')
|
903 |
programacion_img = os.path.join(app.config['UPLOAD_FOLDER'], 'programacion_img.png')
|
904 |
ambulancias_img = os.path.join(app.config['UPLOAD_FOLDER'], 'ambulancias_img.jpg')
|
|
|
907 |
micro = os.path.join(app.config['UPLOAD_FOLDER'], 'micro.png')
|
908 |
ajustes = os.path.join(app.config['UPLOAD_FOLDER'], 'ajustes.png')
|
909 |
flecha = os.path.join(app.config['UPLOAD_FOLDER'], 'flecha.png')
|
910 |
+
#########################################################################################
|
911 |
+
r = sr.Recognizer()
|
912 |
+
|
913 |
+
recognized_text = "" # Valor predeterminado
|
914 |
+
|
915 |
+
if request.method == "POST":
|
916 |
+
f = request.files['audio_data']
|
917 |
+
# Cargar el archivo adjunto directamente
|
918 |
+
with sr.AudioFile(f) as source:
|
919 |
+
audio_data = r.record(source)
|
920 |
+
|
921 |
+
# Realizar el reconocimiento de voz
|
922 |
+
try:
|
923 |
+
recognized_text = r.recognize_google(audio_data, language='es-ES')
|
924 |
+
except sr.UnknownValueError:
|
925 |
+
recognized_text = "No se pudo reconocer el audio"
|
926 |
+
except sr.RequestError as e:
|
927 |
+
recognized_text = f"Error en la solicitud: {str(e)}"
|
928 |
+
print(recognized_text)
|
929 |
+
#return render_template('index.html', recognized_text=recognized_text)
|
930 |
+
|
931 |
+
query=recognized_text
|
932 |
+
#else:
|
933 |
+
##########################################################################################
|
934 |
+
#query = takeCommand()
|
935 |
+
|
936 |
query=str(query).lower()
|
937 |
query=query.split()
|
938 |
+
print(query)
|
939 |
result_busqueda={}
|
940 |
result_busqueda[""]=""
|
941 |
if query[0]!="none":
|
|
|
965 |
if len(output2)==0:
|
966 |
return render_template('escuchar_admision.html',user_image8=mapa_camas_img,user_image9=ambulancias_img,user_image10=programacion_img,user_image11=otros_img,result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha )
|
967 |
else:
|
968 |
+
print("render2")
|
969 |
+
return render_template('buscador_admision.html',faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha,user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales,nid2=0 )
|
970 |
+
#return render_template('escuchar_admision.html',faqs=output2,faq_titulo="Preguntas y respuestas: ",user_image8=mapa_camas_img,user_image9=ambulancias_img,user_image10=programacion_img,user_image11=otros_img,result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha )
|
971 |
else:
|
972 |
return render_template('escuchar_admision.html',user_image8=mapa_camas_img,user_image9=ambulancias_img,user_image10=programacion_img,user_image11=otros_img,prediction_text="No te he entendido bien, dale al boton `Escuchar´ y repite tu pregunta",result_busqueda=result_busqueda, user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha )
|
973 |
|
|
|
1125 |
|
1126 |
@app.route("/escuchar_uro", methods=['GET','POST'])
|
1127 |
async def escuchar_uro():
|
1128 |
+
#########################################################################
|
1129 |
+
|
1130 |
+
lupa = os.path.join(app.config['UPLOAD_FOLDER'], 'lupa.png')
|
1131 |
+
micro = os.path.join(app.config['UPLOAD_FOLDER'], 'micro.png')
|
1132 |
+
ajustes = os.path.join(app.config['UPLOAD_FOLDER'], 'ajustes.png')
|
1133 |
+
flecha = os.path.join(app.config['UPLOAD_FOLDER'], 'flecha.png')
|
1134 |
+
guia_visual_ppt = os.path.join(app.config['UPLOAD_FOLDER'], 'guia_visual.png')
|
1135 |
+
materiales = os.path.join(app.config['UPLOAD_FOLDER'], 'materiales.png')
|
1136 |
+
pdf_casa = os.path.join(app.config['UPLOAD_FOLDER'], 'pdf_casa.jpg')
|
1137 |
+
protocolo_word = os.path.join(app.config['UPLOAD_FOLDER'], 'protocolo.jpg')
|
1138 |
+
visualizar_videos = os.path.join(app.config['UPLOAD_FOLDER'], 'visualizar_video.png')
|
1139 |
+
#################################################################################
|
1140 |
guia_visual_ppt = os.path.join(app.config['UPLOAD_FOLDER'], 'guia_visual.png')
|
1141 |
materiales = os.path.join(app.config['UPLOAD_FOLDER'], 'materiales.png')
|
1142 |
pdf_casa = os.path.join(app.config['UPLOAD_FOLDER'], 'pdf_casa.jpg')
|
|
|
1145 |
micro = os.path.join(app.config['UPLOAD_FOLDER'], 'micro.png')
|
1146 |
ajustes = os.path.join(app.config['UPLOAD_FOLDER'], 'ajustes.png')
|
1147 |
flecha = os.path.join(app.config['UPLOAD_FOLDER'], 'flecha.png')
|
1148 |
+
#########################################################################################
|
1149 |
+
r = sr.Recognizer()
|
1150 |
+
|
1151 |
+
recognized_text = "" # Valor predeterminado
|
1152 |
+
|
1153 |
+
if request.method == "POST":
|
1154 |
+
f = request.files['audio_data']
|
1155 |
+
# Cargar el archivo adjunto directamente
|
1156 |
+
with sr.AudioFile(f) as source:
|
1157 |
+
audio_data = r.record(source)
|
1158 |
+
|
1159 |
+
# Realizar el reconocimiento de voz
|
1160 |
+
try:
|
1161 |
+
recognized_text = r.recognize_google(audio_data, language='es-ES')
|
1162 |
+
except sr.UnknownValueError:
|
1163 |
+
recognized_text = "No se pudo reconocer el audio"
|
1164 |
+
except sr.RequestError as e:
|
1165 |
+
recognized_text = f"Error en la solicitud: {str(e)}"
|
1166 |
+
print(recognized_text)
|
1167 |
+
#return render_template('index.html', recognized_text=recognized_text)
|
1168 |
+
|
1169 |
+
query=recognized_text
|
1170 |
+
#else:
|
1171 |
+
##########################################################################################
|
1172 |
+
#query = takeCommand()
|
1173 |
query=str(query).lower()
|
1174 |
query=query.split()
|
1175 |
result_busqueda={}
|
|
|
1196 |
if len(output2)==0:
|
1197 |
return render_template('escuchar_uro.html',nid2=0,result_busqueda=result_busqueda,user_image6=ajustes,user_image7=flecha,user_image5=micro, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
1198 |
else:
|
1199 |
+
#return render_template('escuchar_uro.html',nid2=0,faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image6=ajustes,user_image7=flecha,user_image5=micro, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
1200 |
+
return render_template('buscador_uro.html',faqs=output2,faq_titulo="Preguntas y respuestas: ",result_busqueda=result_busqueda,user_image4=lupa,user_image5=micro,user_image6=ajustes,user_image7=flecha,user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales,nid2=0 )
|
1201 |
+
|
1202 |
else :
|
1203 |
return render_template('escuchar_uro.html',nid2=0,result_busqueda=result_busqueda,prediction_text="No te he entendido bien, dale al boton `Escuchar´ y repite tu pregunta",user_image5=micro,user_image6=ajustes,user_image7=flecha, user_image8=pdf_casa,user_image9=protocolo_word,user_image10=guia_visual_ppt,user_image11=visualizar_videos,user_image12=materiales )
|
1204 |
|