MariaKaiser commited on
Commit
398ffb2
·
verified ·
1 Parent(s): e65a2fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -537,24 +537,27 @@ async def run_tts_pipeline(task_id: str, story: StoryCreationDTO):
537
  final_path=final_story_path
538
  )
539
 
 
 
 
 
 
 
 
 
 
540
  # 3️⃣ Calculate duration
541
- audio_segment = AudioSegment.from_file(final_generated_story_path)
542
  duration_seconds = len(audio_segment) / 1000 # pydub gives length in milliseconds
543
-
544
  # 4️⃣ Prepare the file for upload
545
- file_name = f"{uuid.uuid4()}_{os.path.basename(final_generated_story_path)}"
546
  storage_path = f"{story.storyId}/final/{file_name}"
547
 
548
  # with open(final_generated_story_path, "rb") as f:
549
  # file_bytes = f.read()
550
 
551
- print(f" final_generated_story_path: {final_generated_story_path}")
552
-
553
- wav = AudioSegment.from_wav(final_generated_story_path)
554
- mp3_path = final_generated_story_path.with_suffix(".mp3")
555
- wav.export(mp3_path, format="mp3", bitrate="192k")
556
 
557
- print(f" final_generated_story_path after conversion to mp3: {mp3_path}")
558
 
559
  supabase.storage.from_("story-audio-files").upload(
560
  storage_path,
 
537
  final_path=final_story_path
538
  )
539
 
540
+ print(f" final_generated_story_path: {final_generated_story_path}")
541
+
542
+ wav = AudioSegment.from_wav(final_generated_story_path)
543
+ mp3_path = final_generated_story_path.with_suffix(".mp3")
544
+ wav.export(mp3_path, format="mp3", bitrate="192k")
545
+
546
+ print(f" final_generated_story_path after conversion to mp3: {mp3_path}")
547
+
548
+
549
  # 3️⃣ Calculate duration
550
+ audio_segment = AudioSegment.from_file(mp3_path)
551
  duration_seconds = len(audio_segment) / 1000 # pydub gives length in milliseconds
552
+
553
  # 4️⃣ Prepare the file for upload
554
+ file_name = f"{uuid.uuid4()}_{os.path.basename(mp3_path)}"
555
  storage_path = f"{story.storyId}/final/{file_name}"
556
 
557
  # with open(final_generated_story_path, "rb") as f:
558
  # file_bytes = f.read()
559
 
 
 
 
 
 
560
 
 
561
 
562
  supabase.storage.from_("story-audio-files").upload(
563
  storage_path,