def general(self, fname): doc = Document(fname) impstr = "empty" finalstr = "" while (impstr != 'ok'): print("tell say ok to stop") obj = tmpspeech() impstr = str(obj.speech()) print(impstr) if (impstr == "ok"): break if (impstr == 'impression'): doc.add_paragraph("Impression :") doc.save(fname) continue print('say final to finalise the spoken statement') str1 = str(obj.speech()) if (str1 == 'final'): print("statement added") finalstr = finalstr + " " + impstr else: continue print(finalstr) l = liver() doc.add_paragraph(finalstr) doc.save(fname) l.replace('full stop', '.', fname) l.replace('into', 'x', fname) l.replace('by', 'x', fname) doc.save(fname)
def clears2(self): while(1): print("tell") obj=tmpspeech() para=str(obj.speech()) print(para) if(len(para)==0): continue else: break return para
def clears(self): while(1): print("tell") obj=tmpspeech() para=str(obj.speech()) print(para) print("speak final to stop") tmp=obj.speech() print(tmp) if(tmp=="final"): break return para
def hyper(self,fname): pa="empty" while(1): print("is RENOVASCULAR_HYPERTENSION found say yes or no") obj=tmpspeech() pa=str(obj.speech()) print(pa) if(pa=="yes" or pa=="no"): break else: continue if(pa=="yes"): self.replace('RENOVASCULAR_HYPERTENSION','Renovascular hypertension found.',fname) else: self.replace('RENOVASCULAR_HYPERTENSION','Renovascular hypertension not found.',fname)
def stone(self,fname): pa="empty" while(1): print("tell stone present or not") obj=tmpspeech() pa=str(obj.speech()) print(pa) if(pa=="present" or pa=="absent"): break else: continue if(pa=='present'): self.replace('STONE','size of kidney stone : K3',fname) print("tell size of kidney stone") para=self.clears() self.replace('K3',para,fname) self.replace('into',' x ',fname) self.replace('by',' x ',fname) else: self.replace('STONE','no echoreflective calculus found.',fname)
def impression(self, fname): doc = Document(fname) impstr = "" finalstr = "" doc.add_paragraph('impression') while (impstr != 'ok'): print("tell") obj = tmpspeech() impstr = str(obj.speech()) print(impstr) if (impstr == "ok"): break finalstr = finalstr + impstr print(finalstr) l = liver() doc.add_paragraph(finalstr) doc.save(fname) l.replace('full stop', '.', fname) l.replace('into', 'x', fname) l.replace('by', 'x', fname) doc.save(fname)
def mainspeech(self): sfinal="empty" import os #from ai.file import time1 #t=time1() from ai.finaldatabase import Database dobj=Database() fcon=dobj.con() rootpath="F:\\speechDB" prootpath=os.path.join("F:\\speechDB","patient") filerootpath="" from ai.tmpspeech import tmpspeech from ai.liver import liver from ai.Paragraph import Paragraph l=liver() p=Paragraph() while(sfinal!="finish"): print('......listening.................') print("say something:") obj=tmpspeech() sfinal=obj.speech() print(sfinal) if(sfinal=='new'): print("in new") reportcnt=1 while(1): print("tell patient name") obj1=tmpspeech() pname=obj1.speech() if(len(pname)==0 or len(pname)>40): continue else: break print(pname) prootpath=os.path.join("F:\\speechDB","patient") idcnt=dobj.getIdcnt(fcon) tmpcnt=str(idcnt) prootpath=prootpath+str(idcnt) if not os.path.exists(prootpath): os.makedirs(prootpath) filerootpath=prootpath+'\\'+pname+str(reportcnt)+'.docx' dobj.insertptable(fcon,idcnt,pname,reportcnt) dobj.insertlink(fcon,idcnt,filerootpath,"") dobj.insertroot(fcon,idcnt,prootpath) print(filerootpath) idcnt=idcnt+1 dobj.insertinfo(fcon,idcnt) l.createf(filerootpath) l.filecopy(filerootpath) l.p1(filerootpath,pname) l.id2(filerootpath,tmpcnt) if(sfinal=='update'): print("in update") while(1): print("tell patient id") obj1=tmpspeech() id1=obj1.speech() print(id1) if(len(id1)==0 or any(c.isalpha() for c in id1)): continue else: pid=int(id1) pname=dobj.getpname(fcon,pid) if(len(pname)==0): print("incorrect id") continue else: break print(pname) prootpath=dobj.getpath(fcon,pid) prcnt=dobj.getrcnt(fcon,pid) prcnt=prcnt+1 dobj.updatecnt(fcon,pid,prcnt) filerootpath=prootpath+'\\'+pname+str(prcnt)+'.docx' print(filerootpath) dobj.insertlink(fcon,pid,filerootpath,"") l.createf(filerootpath) l.filecopy(filerootpath) l.id2(filerootpath,id1) l.p1(filerootpath,pname) if(sfinal=='paragraph'): print("in paragraph") print("tell paragraph name that you want to include or copy normal para") obj2=tmpspeech() pstr=str(obj2.speech()) print(pstr) if(pstr=='liver'): print("liver para added") p.liverP(filerootpath) if(pstr=='gallbladder'): print("gall badder para added") p.gallbladder(filerootpath) if(pstr=='kidney'): print("kidney para added") p.kidney(filerootpath) if(sfinal=='general'): print("in general") p.general(filerootpath) if(sfinal=='kidney parameter'): print("for left kidney tell size") l.k1(filerootpath) print("for right kidney tell size") l.k2(filerootpath) #print("tell stone present or not") l.stone(filerootpath) l.hyper(filerootpath) if(sfinal=="liver parameter"): print(" does liver contours appear normal or abnormal? ") l.l5(filerootpath) print("Is Focal mass lesion present or absent?") l.l1(filerootpath) print("Does The portal vein and C.B.D appear normal or abnormal?") l.l2(filerootpath) print("Is liver is fatty or not say yes or no") l.l3(filerootpath) print("Does hepatic portal and venous system appear normal or abnormal?") l.l4(filerootpath) if(sfinal=="display"): print("in display") l.display(filerootpath)