capradeepgujaran commited on
Commit
4e6b972
1 Parent(s): 503a035

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import os
2
  import cv2
3
  import numpy as np
@@ -84,7 +86,7 @@ def extract_text_from_pdf(pdf_path, lang='eng'):
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,16 +250,16 @@ def create_gradio_interface():
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,4 +269,4 @@ def create_gradio_interface():
267
 
268
  if __name__ == "__main__":
269
  demo = create_gradio_interface()
270
- demo.launch()
 
1
+ # app.py
2
+
3
  import os
4
  import cv2
5
  import numpy as np
 
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
  outputs=[text_input]
251
  )
252
 
253
+ def process_generation(api_key, input_text, model_name, voice_type, voice_speed, language, output_option):
254
+ """Wrapper function to process generation with updated parameters"""
255
  # Convert language name to code
256
+ language_code = LANGUAGE_CODES.get(language, "en") # Default to English if not found
257
+ return generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_speed, language_code, output_option)
258
 
259
  generate_button.click(
260
  fn=process_generation,
261
  inputs=[
262
+ api_key_input, text_input, "gpt-4o-mini", voice_type,
263
  voice_speed, language, output_option
264
  ],
265
  outputs=[audio_output, script_output, status_output]
 
269
 
270
  if __name__ == "__main__":
271
  demo = create_gradio_interface()
272
+ demo.launch()