How to use the moviepy.audio.io.AudioFileClip.AudioFileClip function in moviepy

To help you get started, we’ve selected a few moviepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Zulko / moviepy / tests / test_AudioClips.py View on Github external
def test_audio_coreader():
    if sys.platform.startswith("win"):
        pytest.skip("Temporarily skipping on windows because otherwise test suite fails with Invalid Handle Error")

    sound = AudioFileClip("media/crunching.mp3")
    sound = sound.subclip(1, 4)
    sound2 = AudioFileClip("media/crunching.mp3")
    sound2.write_audiofile(os.path.join(TMP_DIR, "coreader.mp3"))
github Zulko / moviepy / tests / test_fx.py View on Github external
def test_normalize():
    clip = AudioFileClip('media/crunching.mp3')
    clip = audio_normalize(clip)
    assert clip.max_volume() == 1
    close_all_clips(locals())
github Zulko / moviepy / tests / test_AudioClips.py View on Github external
def test_audioclip_with_file_concat():
    if sys.platform.startswith("win"):
        pytest.skip("Temporarily skipping on windows because otherwise test suite fails with Invalid Handle Error")

    make_frame_440 = lambda t: [sin(440 * 2 * pi * t)]
    clip1 = AudioClip(make_frame_440, duration=1, fps=44100)

    clip2 = AudioFileClip("media/crunching.mp3")

    concat_clip = concatenate_audioclips((clip1, clip2))

    return
    # Fails with strange error
    # "ValueError: operands could not be broadcast together with
    # shapes (1993,2) (1993,1993)1
    concat_clip.write_audiofile(os.path.join(TMP_DIR, "concat_clip_with_file_audio.mp3"))
github hipstas / audio-tagging-toolkit / attk / utils.py View on Github external
def subclip_list(media_path, range_pairs, out_dir=''):
    if out_dir=='':
        out_dir = os.path.dirname(media_path)
    snd = AudioFileClip.AudioFileClip(media_path)
    file_duration = duration(media_path)
    for pair in range_pairs:
        start = pair[0]
        duration_secs = pair[1]
        if (float(start) >= 0.0) & (float(duration_secs) > 0.0):
            if start + duration_secs > file_duration:
                duration_secs = file_duration - start
            basename = media_path.split('/')[-1][:-4]
            out_filename = basename+'__'+str(round(start, 4))+'_'+str(round(duration_secs ,4))+'.wav'
            snd.subclip(float(start),float(start)+float(duration_secs)).write_audiofile(os.path.join(out_dir, out_filename))
github hipstas / audio-tagging-toolkit / attk / utils.py View on Github external
def subclip(media_path,start_time,end_time,out_dir=''):
    if out_dir=='':
        out_dir = os.path.dirname(media_path)
    audio_filename=media_path.split('/')[-1]
    basename = audio_filename[:-4]
    start_time = round(float(start_time),3)
    end_time = round(float(end_time),3)
    snd = AudioFileClip.AudioFileClip(media_path)
    out_filename = basename+'__'+str(start_time)+'_'+str(end_time)+'.wav'
    snd.subclip(start_time,end_time).write_audiofile(os.path.join(out_dir,out_filename))
    return os.path.join(out_dir,out_filename)
github Zulko / moviepy / moviepy / audio / io / AudioFileClip.py View on Github external
def coreader(self):
        """ Returns a copy of the AudioFileClip, i.e. a new entrance point
            to the audio file. Use copy when you have different clips
            watching the audio file at different times. """
        return AudioFileClip(self.filename, self.buffersize)
github tyarkoni / pliers / pliers / stimuli / audio.py View on Github external
def _load_clip(self):
        self.clip = AudioFileClip(self.filename, fps=self.sampling_rate)
github tyarkoni / pliers / pliers / stimuli / audio.py View on Github external
def _load_clip(self):
        self.clip = AudioFileClip(self.filename, fps=self.sampling_rate)