broadfield commited on
Commit
6d5b659
·
verified ·
1 Parent(s): 9373b6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -21,7 +21,8 @@ def read_pdf(pdf_url):
21
  print(response.status_code)
22
  if not os.path.isdir("./images"):
23
  os.mkdir("./images")
24
- text=[]
 
25
  images = ""
26
  reader = PdfReader(file_name)
27
  number_of_pages = len(reader.pages)
@@ -40,9 +41,9 @@ def read_pdf(pdf_url):
40
  #text = f'{text}\n{page.extract_text()}'
41
  else:
42
  images=""
43
-
44
- text.append({"page":i,"text":page.extract_text(),"images":images})
45
- return text
46
  def stream_aud(url):
47
  inp=read_pdf(url)
48
  for ea in inp:
@@ -65,7 +66,10 @@ function start() {
65
  with gr.Blocks() as app:
66
  a=gr.Audio(streaming=True,autoplay=True)
67
  h=gr.HTML()
68
- t=gr.Textbox(interactive=False)
 
 
69
  app.load(None,None,t,js=js)
70
- t.change(load_html,t,h).then(stream_aud,t,a)
 
71
  app.launch()
 
21
  print(response.status_code)
22
  if not os.path.isdir("./images"):
23
  os.mkdir("./images")
24
+ pdf_json=[]
25
+ txt_out=""
26
  images = ""
27
  reader = PdfReader(file_name)
28
  number_of_pages = len(reader.pages)
 
41
  #text = f'{text}\n{page.extract_text()}'
42
  else:
43
  images=""
44
+ txt_out+=page.extract_text()
45
+ pdf_json.append({"page":i,"text":page.extract_text(),"images":images})
46
+ return pdf_json,txt_out
47
  def stream_aud(url):
48
  inp=read_pdf(url)
49
  for ea in inp:
 
66
  with gr.Blocks() as app:
67
  a=gr.Audio(streaming=True,autoplay=True)
68
  h=gr.HTML()
69
+ t=gr.Textbox(label="url",interactive=False)
70
+ bulk=gr.Textbox(label="bulk",interactive=False)
71
+
72
  app.load(None,None,t,js=js)
73
+
74
+ t.change(read_pdf,t,[h,bulk]).then(pp.stream_tts,bulk,a)
75
  app.launch()