lodhrangpt commited on
Commit
0771afb
·
verified ·
1 Parent(s): 427442a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -12,11 +12,9 @@ try:
12
  except:
13
  print("NLTK punkt tokenizer download failed. Using custom tokenizer.")
14
 
15
- # Custom fallback for sentence tokenization
16
  def custom_sent_tokenize(text):
17
  return text.split(". ")
18
 
19
- # Function to send audio to Groq API and get transcription
20
  def transcribe(audio_path):
21
  with open(audio_path, "rb") as audio_file:
22
  audio_data = audio_file.read()
@@ -97,7 +95,10 @@ def create_pdf(transcript, long_questions, short_questions, mcqs):
97
  pdf.multi_cell(0, 10, f" - {option}")
98
  pdf.multi_cell(0, 10, f"Answer: {mcq['answer']}\n")
99
 
100
- pdf_path = "/mnt/data/transcription_notes.pdf"
 
 
 
101
  pdf.output(pdf_path)
102
 
103
  return pdf_path
@@ -110,7 +111,9 @@ def create_error_pdf(message):
110
  pdf.set_font("Arial", "", 12)
111
  pdf.multi_cell(0, 10, message)
112
 
113
- error_pdf_path = "/mnt/data/error_report.pdf"
 
 
114
  pdf.output(error_pdf_path)
115
  return error_pdf_path
116
 
 
12
  except:
13
  print("NLTK punkt tokenizer download failed. Using custom tokenizer.")
14
 
 
15
  def custom_sent_tokenize(text):
16
  return text.split(". ")
17
 
 
18
  def transcribe(audio_path):
19
  with open(audio_path, "rb") as audio_file:
20
  audio_data = audio_file.read()
 
95
  pdf.multi_cell(0, 10, f" - {option}")
96
  pdf.multi_cell(0, 10, f"Answer: {mcq['answer']}\n")
97
 
98
+ # Ensure the output directory exists
99
+ output_dir = "/mnt/data"
100
+ os.makedirs(output_dir, exist_ok=True)
101
+ pdf_path = os.path.join(output_dir, "transcription_notes.pdf")
102
  pdf.output(pdf_path)
103
 
104
  return pdf_path
 
111
  pdf.set_font("Arial", "", 12)
112
  pdf.multi_cell(0, 10, message)
113
 
114
+ output_dir = "/mnt/data"
115
+ os.makedirs(output_dir, exist_ok=True)
116
+ error_pdf_path = os.path.join(output_dir, "error_report.pdf")
117
  pdf.output(error_pdf_path)
118
  return error_pdf_path
119