Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update app.py
Browse files
    	
        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  | 
| 64 | 
            -
                for i in range(0, len(words), 3):  #  | 
| 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:
         |