drewThomasson commited on
Commit
4a7d9b6
·
verified ·
1 Parent(s): 30af7c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import os
 
3
  import subprocess
4
 
5
  # Declare the global variable
@@ -7,7 +8,18 @@ gradio_input_file = None
7
 
8
  def process_ebook(ebook_file):
9
  global gradio_input_file # Use the global variable to store the ebook file path
10
- gradio_input_file = ebook_file # Assign the file path to the global variable
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Print the name of the uploaded file
13
  ebook_file_name = os.path.basename(ebook_file)
@@ -67,7 +79,7 @@ with gr.Blocks() as gui:
67
  download_button = gr.Button("Reload Files")
68
  file_output = gr.Files(
69
  label="Generated Audiobook Files",
70
- type='file' # Use 'file' type for gr.Files component
71
  )
72
 
73
  # Update the file_output component with the list of output files
 
1
  import gradio as gr
2
  import os
3
+ import shutil
4
  import subprocess
5
 
6
  # Declare the global variable
 
8
 
9
  def process_ebook(ebook_file):
10
  global gradio_input_file # Use the global variable to store the ebook file path
11
+
12
+ # Create input_files directory if it doesn't exist
13
+ input_dir = "input_files"
14
+ if not os.path.exists(input_dir):
15
+ os.mkdir(input_dir)
16
+
17
+ # Copy the uploaded file to input_files folder
18
+ input_file_path = os.path.join(input_dir, os.path.basename(ebook_file))
19
+ shutil.copy(ebook_file, input_file_path)
20
+
21
+ # Set the file path to the global variable
22
+ gradio_input_file = input_file_path
23
 
24
  # Print the name of the uploaded file
25
  ebook_file_name = os.path.basename(ebook_file)
 
79
  download_button = gr.Button("Reload Files")
80
  file_output = gr.Files(
81
  label="Generated Audiobook Files",
82
+ type='filepath' # Use 'filepath' type for gr.Files component
83
  )
84
 
85
  # Update the file_output component with the list of output files