drewThomasson
commited on
should be able to see the VoxNovel terminal print outs now
Browse files
app.py
CHANGED
@@ -6,27 +6,30 @@ import subprocess
|
|
6 |
def process_ebook(ebook_file):
|
7 |
# Ensure input_files folder exists
|
8 |
input_dir = "input_files"
|
9 |
-
output_dir = "output_audiobooks"
|
10 |
os.makedirs(input_dir, exist_ok=True)
|
11 |
|
12 |
# Save the uploaded file to the input_files folder
|
13 |
ebook_file_path = os.path.join(input_dir, ebook_file.name)
|
14 |
shutil.move(ebook_file.name, ebook_file_path)
|
15 |
|
16 |
-
# Call the Auto_VoxNovel.py script and
|
17 |
try:
|
18 |
-
|
19 |
-
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
except Exception as e:
|
28 |
return f"Failed to run audiobook script: {str(e)}"
|
29 |
|
|
|
30 |
def list_output_files():
|
31 |
# List all files in the output directory for downloading
|
32 |
output_dir = "output_audiobooks"
|
|
|
6 |
def process_ebook(ebook_file):
|
7 |
# Ensure input_files folder exists
|
8 |
input_dir = "input_files"
|
|
|
9 |
os.makedirs(input_dir, exist_ok=True)
|
10 |
|
11 |
# Save the uploaded file to the input_files folder
|
12 |
ebook_file_path = os.path.join(input_dir, ebook_file.name)
|
13 |
shutil.move(ebook_file.name, ebook_file_path)
|
14 |
|
15 |
+
# Call the Auto_VoxNovel.py script and stream its output live
|
16 |
try:
|
17 |
+
process = subprocess.Popen(["python3", "Auto_VoxNovel.py"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
18 |
+
|
19 |
+
# Print output in real-time
|
20 |
+
for line in process.stdout:
|
21 |
+
print(line, end='')
|
22 |
+
|
23 |
+
process.wait()
|
24 |
+
|
25 |
+
if process.returncode == 0:
|
26 |
+
return "Audiobook is ready! You can now download your files below."
|
27 |
+
else:
|
28 |
+
return "Error occurred during audiobook processing."
|
29 |
except Exception as e:
|
30 |
return f"Failed to run audiobook script: {str(e)}"
|
31 |
|
32 |
+
|
33 |
def list_output_files():
|
34 |
# List all files in the output directory for downloading
|
35 |
output_dir = "output_audiobooks"
|