Neurolingua
commited on
Commit
•
754b631
1
Parent(s):
2f02b6a
Update student_functions.py
Browse files- student_functions.py +18 -1
student_functions.py
CHANGED
@@ -20,7 +20,7 @@ chrome_options.add_argument("--disable-extensions")
|
|
20 |
chrome_options.add_argument("--no-sandbox")
|
21 |
chrome_options.add_argument("--disable-dev-shm-usage")
|
22 |
|
23 |
-
|
24 |
AI71_API_KEY = "api71-api-652e5c6c-8edf-41d0-9c34-28522b07bef9"
|
25 |
|
26 |
|
@@ -30,6 +30,23 @@ 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 |
return text
|
34 |
|
35 |
|
|
|
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 |
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 |
|