hivecorp commited on
Commit
385d7a8
Β·
verified Β·
1 Parent(s): a2b6969

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -4,6 +4,9 @@ import asyncio
4
  import tempfile
5
  import os
6
  from moviepy.editor import AudioFileClip
 
 
 
7
 
8
  # θŽ·ε–ζ‰€ζœ‰ε―η”¨ηš„θ―­ιŸ³
9
  async def get_voices():
@@ -26,7 +29,7 @@ async def text_to_speech(text, voice, rate, pitch):
26
  await communicate.save(tmp_path)
27
  return tmp_path, None
28
 
29
- # SRTζ–‡δ»Άη”Ÿζˆ
30
  def generate_srt(words, audio_clips):
31
  srt_path = os.path.join(tempfile.gettempdir(), "output_subtitles.srt")
32
  with open(srt_path, 'w', encoding='utf-8') as srt_file:
@@ -60,8 +63,8 @@ async def text_to_audio_and_srt(text, voice, rate, pitch):
60
  audio_clips = []
61
  subtitle_chunks = []
62
 
63
- # Generate audio for each word and adjust chunk size dynamically
64
- for i in range(0, len(words), 3): # Initial chunk size of 3 words
65
  chunk = ' '.join(words[i:i + 3]) # Create a chunk of 3 words
66
  audio, warning = await text_to_speech(chunk, voice, rate, pitch)
67
  if warning:
 
4
  import tempfile
5
  import os
6
  from moviepy.editor import AudioFileClip
7
+ from wand.image import Image
8
+ from wand.drawing import Drawing
9
+ from wand.color import Color
10
 
11
  # θŽ·ε–ζ‰€ζœ‰ε―η”¨ηš„θ―­ιŸ³
12
  async def get_voices():
 
29
  await communicate.save(tmp_path)
30
  return tmp_path, None
31
 
32
+ # η”ŸζˆSRTζ–‡δ»Ά
33
  def generate_srt(words, audio_clips):
34
  srt_path = os.path.join(tempfile.gettempdir(), "output_subtitles.srt")
35
  with open(srt_path, 'w', encoding='utf-8') as srt_file:
 
63
  audio_clips = []
64
  subtitle_chunks = []
65
 
66
+ # Generate audio for each chunk of 3 words
67
+ for i in range(0, len(words), 3): # Adjust chunk size if needed
68
  chunk = ' '.join(words[i:i + 3]) # Create a chunk of 3 words
69
  audio, warning = await text_to_speech(chunk, voice, rate, pitch)
70
  if warning: