drewThomasson commited on
Commit
d040eb4
·
verified ·
1 Parent(s): 715bfbb

should be able to see the VoxNovel terminal print outs now

Browse files
Files changed (1) hide show
  1. app.py +14 -11
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 wait for it to finish
17
  try:
18
- #result = subprocess.run(["python3", "Auto_VoxNovel.py"], capture_output=True, text=True)
19
- import Auto_VoxNovel
20
- #if result.returncode == 0:
21
- # # Success message when the audiobook is ready
22
- # return "Audiobook is ready! You can now download your files below."
23
- #else:
24
- # # Error message if something went wrong
25
- # return f"Error: {result.stderr}"
26
- return "Audiobook is ready! You can now download your files below."
 
 
 
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"