yasserrmd commited on
Commit
c634737
·
verified ·
1 Parent(s): 3cae7e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -6,6 +6,7 @@ from generate_transcript import TranscriptProcessor
6
  from generate_audio import TTSGenerator
7
  import pickle
8
  import os
 
9
  import spaces
10
 
11
  # Define paths
@@ -16,9 +17,23 @@ tts_ready_path = './resources/podcast_ready_data.pkl'
16
  audio_output_path = 'final_podcast_audio.mp3'
17
 
18
 
 
 
 
 
19
  # Combined function to perform all steps sequentially
20
  @spaces.GPU
21
  def process_pdf_to_podcast(pdf_file):
 
 
 
 
 
 
 
 
 
 
22
  # Step 1: Extract Text from PDF
23
  with open(pdf_path, 'wb') as f:
24
  f.write(pdf_file.read())
 
6
  from generate_audio import TTSGenerator
7
  import pickle
8
  import os
9
+ import tempfile
10
  import spaces
11
 
12
  # Define paths
 
17
  audio_output_path = 'final_podcast_audio.mp3'
18
 
19
 
20
+
21
+ def create_temp_session_directory():
22
+ return tempfile.mkdtemp()
23
+
24
  # Combined function to perform all steps sequentially
25
  @spaces.GPU
26
  def process_pdf_to_podcast(pdf_file):
27
+
28
+ session_dir = create_temp_session_directory()
29
+
30
+ # Define paths within the session directory
31
+ pdf_path = os.path.join(session_dir, "uploaded_pdf.pdf")
32
+ clean_text_path = os.path.join(session_dir, "clean_text.txt")
33
+ transcript_path = os.path.join(session_dir, "data.pkl")
34
+ tts_ready_path = os.path.join(session_dir, "podcast_ready_data.pkl")
35
+ audio_output_path = os.path.join(session_dir, "final_podcast_audio.mp3")
36
+
37
  # Step 1: Extract Text from PDF
38
  with open(pdf_path, 'wb') as f:
39
  f.write(pdf_file.read())