Bils commited on
Commit
1b36a14
·
verified ·
1 Parent(s): 03cee98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -35,7 +35,7 @@ MUSICGEN_MODELS = {}
35
  TTS_MODELS = {}
36
 
37
  # ---------------------------------------------------------------------
38
- # Utility Function: Clean Text
39
  # ---------------------------------------------------------------------
40
  def clean_text(text: str) -> str:
41
  """
@@ -127,7 +127,7 @@ def generate_script(user_prompt: str, model_id: str, token: str, duration: int):
127
  if "Output:" in generated_text:
128
  generated_text = generated_text.split("Output:")[-1].strip()
129
 
130
- # Try to extract sections using regex; fall back to defaults if not found.
131
  pattern = r"Voice-Over Script:\s*(.*?)\s*Sound Design Suggestions:\s*(.*?)\s*Music Suggestions:\s*(.*)"
132
  match = re.search(pattern, generated_text, re.DOTALL)
133
  if match:
@@ -222,16 +222,16 @@ def blend_audio(voice_path: str, music_path: str, ducking: bool, duck_level: int
222
  voice = AudioSegment.from_wav(voice_path)
223
  music = AudioSegment.from_wav(music_path)
224
 
225
- voice_len = len(voice) # in milliseconds
226
 
227
- # Loop music if it's shorter than voice
228
  if len(music) < voice_len:
229
  looped_music = AudioSegment.empty()
230
  while len(looped_music) < voice_len:
231
  looped_music += music
232
  music = looped_music
233
 
234
- # Trim music to match voice duration
235
  music = music[:voice_len]
236
 
237
  if ducking:
@@ -250,7 +250,7 @@ def blend_audio(voice_path: str, music_path: str, ducking: bool, duck_level: int
250
 
251
 
252
  # ---------------------------------------------------------------------
253
- # Gradio Interface with Enhanced UI for Ai Ads Promo
254
  # ---------------------------------------------------------------------
255
  with gr.Blocks(css="""
256
  /* Global Styles */
@@ -298,7 +298,7 @@ with gr.Blocks(css="""
298
  <p>Your all-in-one AI solution for creating professional audio ads.</p>
299
  """)
300
 
301
- # Enhanced Description with Simple, Human-Friendly Language
302
  gr.Markdown("""
303
  **Welcome to Ai Ads Promo!**
304
 
 
35
  TTS_MODELS = {}
36
 
37
  # ---------------------------------------------------------------------
38
+ # Utility Function
39
  # ---------------------------------------------------------------------
40
  def clean_text(text: str) -> str:
41
  """
 
127
  if "Output:" in generated_text:
128
  generated_text = generated_text.split("Output:")[-1].strip()
129
 
130
+
131
  pattern = r"Voice-Over Script:\s*(.*?)\s*Sound Design Suggestions:\s*(.*?)\s*Music Suggestions:\s*(.*)"
132
  match = re.search(pattern, generated_text, re.DOTALL)
133
  if match:
 
222
  voice = AudioSegment.from_wav(voice_path)
223
  music = AudioSegment.from_wav(music_path)
224
 
225
+ voice_len = len(voice)
226
 
227
+
228
  if len(music) < voice_len:
229
  looped_music = AudioSegment.empty()
230
  while len(looped_music) < voice_len:
231
  looped_music += music
232
  music = looped_music
233
 
234
+
235
  music = music[:voice_len]
236
 
237
  if ducking:
 
250
 
251
 
252
  # ---------------------------------------------------------------------
253
+ # Gradio Interface
254
  # ---------------------------------------------------------------------
255
  with gr.Blocks(css="""
256
  /* Global Styles */
 
298
  <p>Your all-in-one AI solution for creating professional audio ads.</p>
299
  """)
300
 
301
+
302
  gr.Markdown("""
303
  **Welcome to Ai Ads Promo!**
304