0

I'm coding something to edit video automatically but when I wanted to create automatic subtitles there was a problem with image magick

As I told you I did something to add automatic subtitles but image magick gave me this error:

https://pastebin.com/nthzDdnR

the part of my code that bugs where I added the subtitles (I have already imported imagemagick and checked for updates):

while current_time < duration:
 actuel
    audio = video.subclip(current_time, current_time+5).audio


    audio_array = audio.to_soundarray()

    audio_data = sr.AudioData(np.int16(audio_array), audio.fps, audio_array.shape[1])

    try:
        text = r.recognize_google(audio_data, language="fr-FR")
    except sr.UnknownValueError:
        text = ""

    subtitles.append(((current_time, current_time+5), text))

    current_time += 5

subtitles_clip = SubtitlesClip(subtitles)

for sub in subtitles:
    subtitles_clip = subtitles_clip.set_duration(subtitles_clip.duration + sub[1]-sub[0])
    subtitles_clip = subtitles_clip.add_mask()
    subtitles_clip = subtitles_clip.add(
        TextClip(sub[2], font="Arial", fontsize=24, color="white", stroke_width=0.5)
        .set_start(sub[0])
        .set_end(sub[1])
    )

video = CompositeVideoClip([video, subtitles_clip.set_position(("center", "bottom"))])

0 Answers0