capradeepgujaran commited on
Commit
3c2a48e
1 Parent(s): 25a5bf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -1,5 +1,3 @@
1
- # app.py
2
-
3
  import os
4
  import cv2
5
  import numpy as np
@@ -86,7 +84,7 @@ def extract_text_from_pdf(pdf_path, lang='eng'):
86
  for page_num in range(len(pdf_reader.pages)):
87
  page = pdf_reader.pages[page_num]
88
  page_text = page.extract_text()
89
- if page_text and page_text.strip():
90
  text += page_text
91
  else:
92
  images = convert_from_path(pdf_path, first_page=page_num + 1, last_page=page_num + 1)
@@ -250,17 +248,16 @@ def create_gradio_interface():
250
  outputs=[text_input]
251
  )
252
 
253
- def process_generation(api_key, input_text, voice_type, voice_speed, language, output_option):
254
- """Wrapper function to process generation with updated parameters"""
255
- model_name = "gpt-4o-mini" # Fixed model name
256
  # Convert language name to code
257
- language_code = LANGUAGE_CODES.get(language, "en") # Default to English if not found
258
- return generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_speed, language_code, output_option)
259
 
260
  generate_button.click(
261
  fn=process_generation,
262
  inputs=[
263
- api_key_input, text_input, voice_type,
264
  voice_speed, language, output_option
265
  ],
266
  outputs=[audio_output, script_output, status_output]
@@ -270,4 +267,4 @@ def create_gradio_interface():
270
 
271
  if __name__ == "__main__":
272
  demo = create_gradio_interface()
273
- demo.launch()
 
 
 
1
  import os
2
  import cv2
3
  import numpy as np
 
84
  for page_num in range(len(pdf_reader.pages)):
85
  page = pdf_reader.pages[page_num]
86
  page_text = page.extract_text()
87
+ if page_text.strip():
88
  text += page_text
89
  else:
90
  images = convert_from_path(pdf_path, first_page=page_num + 1, last_page=page_num + 1)
 
248
  outputs=[text_input]
249
  )
250
 
251
+ def process_generation(*args):
252
+ args = list(args)
 
253
  # Convert language name to code
254
+ args[5] = LANGUAGE_CODES[args[5]]
255
+ return generate_audio_and_text(*args)
256
 
257
  generate_button.click(
258
  fn=process_generation,
259
  inputs=[
260
+ api_key_input, text_input, model_dropdown, voice_type,
261
  voice_speed, language, output_option
262
  ],
263
  outputs=[audio_output, script_output, status_output]
 
267
 
268
  if __name__ == "__main__":
269
  demo = create_gradio_interface()
270
+ demo.launch()