Neurolingua commited on
Commit
6ce680d
1 Parent(s): c131296

Update student_functions.py

Browse files
Files changed (1) hide show
  1. student_functions.py +2 -25
student_functions.py CHANGED
@@ -13,14 +13,7 @@ from urllib.parse import urlparse, parse_qs
13
  from pypdf import PdfReader
14
  from ai71 import AI71
15
  import os
16
- chrome_options = webdriver.ChromeOptions()
17
- chrome_options.add_argument("--headless")
18
- chrome_options.add_argument("--disable-gpu")
19
- chrome_options.add_argument("--disable-extensions")
20
- chrome_options.add_argument("--no-sandbox")
21
- chrome_options.add_argument("--disable-dev-shm-usage")
22
-
23
- driver = webdriver.Chrome(options=chrome_options)
24
  AI71_API_KEY = "api71-api-652e5c6c-8edf-41d0-9c34-28522b07bef9"
25
 
26
 
@@ -30,23 +23,7 @@ def extract_text_from_pdf_s(pdf_path):
30
  for page in reader.pages:
31
  text += page.extract_text() + "\n"
32
  generate_speech_from_pdf(text[:len(text) // 2])
33
- directory = 'uploads'
34
- keep_file = 'nil.txt'
35
-
36
- # Check if the directory exists
37
- if os.path.isdir(directory):
38
- for filename in os.listdir(directory):
39
- file_path = os.path.join(directory, filename)
40
-
41
- # Check if the current file is not the one to keep and is a file
42
- if filename != keep_file and os.path.isfile(file_path):
43
- try:
44
- os.remove(file_path) # Delete the file
45
- print(f"Deleted {file_path}")
46
- except Exception as e:
47
- print(f"Error deleting {file_path}: {e}")
48
- else:
49
- print(f"Directory {directory} does not exist.")
50
  return text
51
 
52
 
 
13
  from pypdf import PdfReader
14
  from ai71 import AI71
15
  import os
16
+
 
 
 
 
 
 
 
17
  AI71_API_KEY = "api71-api-652e5c6c-8edf-41d0-9c34-28522b07bef9"
18
 
19
 
 
23
  for page in reader.pages:
24
  text += page.extract_text() + "\n"
25
  generate_speech_from_pdf(text[:len(text) // 2])
26
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  return text
28
 
29