Update app.py
Browse files
app.py
CHANGED
@@ -10,15 +10,18 @@ def process_ebook(ebook_file):
|
|
10 |
|
11 |
# Save the uploaded file to the input_files folder
|
12 |
ebook_file_path = os.path.join(input_dir, ebook_file.name)
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
# List the contents of the input_files folder
|
16 |
input_files_list = os.listdir(input_dir)
|
17 |
input_files_str = "\n".join(input_files_list)
|
18 |
-
|
19 |
# Print the list of input files in the terminal
|
20 |
print("Files in input_files folder:", input_files_str)
|
21 |
-
|
22 |
# Call the Auto_VoxNovel.py script and stream its output live
|
23 |
try:
|
24 |
process = subprocess.Popen(["python3", "Auto_VoxNovel.py"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
@@ -30,11 +33,12 @@ def process_ebook(ebook_file):
|
|
30 |
process.wait()
|
31 |
|
32 |
if process.returncode == 0:
|
33 |
-
return "Audiobook is ready! You can now download your files below
|
34 |
else:
|
35 |
-
return "Error occurred during audiobook processing
|
36 |
except Exception as e:
|
37 |
-
return f"Failed to run audiobook script: {str(e)}"
|
|
|
38 |
|
39 |
|
40 |
def list_output_files():
|
|
|
10 |
|
11 |
# Save the uploaded file to the input_files folder
|
12 |
ebook_file_path = os.path.join(input_dir, ebook_file.name)
|
13 |
+
|
14 |
+
# Only copy the file if it's not already in the destination folder
|
15 |
+
if ebook_file_path != ebook_file.name:
|
16 |
+
shutil.copy(ebook_file.name, ebook_file_path)
|
17 |
+
|
18 |
# List the contents of the input_files folder
|
19 |
input_files_list = os.listdir(input_dir)
|
20 |
input_files_str = "\n".join(input_files_list)
|
21 |
+
|
22 |
# Print the list of input files in the terminal
|
23 |
print("Files in input_files folder:", input_files_str)
|
24 |
+
|
25 |
# Call the Auto_VoxNovel.py script and stream its output live
|
26 |
try:
|
27 |
process = subprocess.Popen(["python3", "Auto_VoxNovel.py"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
|
|
33 |
process.wait()
|
34 |
|
35 |
if process.returncode == 0:
|
36 |
+
return f"Audiobook is ready! You can now download your files below.\n\nInput files:\n{input_files_str}"
|
37 |
else:
|
38 |
+
return f"Error occurred during audiobook processing.\n\nInput files:\n{input_files_str}"
|
39 |
except Exception as e:
|
40 |
+
return f"Failed to run audiobook script: {str(e)}\n\nInput files:\n{input_files_str}"
|
41 |
+
|
42 |
|
43 |
|
44 |
def list_output_files():
|