Skip to content

Commit

Permalink
update moviepy api
Browse files Browse the repository at this point in the history
  • Loading branch information
yajrendrag committed Nov 23, 2024
1 parent 5fbe356 commit 81c9444
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions source/detect_audio_language/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

**<span style="color:#56adda">0.0.10</span>**
- update moviepy to 2.0 api

**<span style="color:#56adda">0.0.9</span>**
- fix construction of temp video files to use glob

Expand Down
2 changes: 1 addition & 1 deletion source/detect_audio_language/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"on_worker_process": 1
},
"tags": "audio",
"version": "0.0.9"
"version": "0.0.10"
}
8 changes: 4 additions & 4 deletions source/detect_audio_language/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from pathlib import Path
import subprocess
import random
import moviepy.editor as mp
from moviepy import *
import shutil
import os
import glob
Expand Down Expand Up @@ -159,11 +159,11 @@ def detect_language(video_file, tmp_dir):
logger.debug("video_file: '{}'; tmp_dir: '{}'".format(video_file, tmp_dir))

# Load video and get duration
video = mp.VideoFileClip(video_file)
video = VideoFileClip(video_file)
duration = video.duration

# Define subclip to start 10 minutes into video and end 7 minutes before end
video = video.subclip(600, duration-430)
video = video.with_subclip(600, duration-430)
duration = video.duration - 30

if duration < 600:
Expand All @@ -180,7 +180,7 @@ def detect_language(video_file, tmp_dir):
for sample_time in sample_times:

# Extract 30 seconds of audio clip from the video
audio_clip = video.subclip(sample_time, sample_time + 30)
audio_clip = video.with_subclip(sample_time, sample_time + 30)
audio_file = f"{tmp_dir}/sample_{str(sample_time)}.wav"
audio_clip.audio.write_audiofile(audio_file, codec='pcm_s16le')
logger.debug("audio_file: '{}'".format(audio_file))
Expand Down

0 comments on commit 81c9444

Please sign in to comment.