Example #1
0
def save_video(clips, path):
    make_directory(path.parent)
    clips.write_videofile(str(path),
                          fps=1,
                          audio_codec='aac',
                          preset='ultrafast')
    clips.close()
Example #2
0
def resize_image_directory(img_dir, out_dir):
    """
    img_dir (Path) -- directory to recursively search, resize images
    out_dir (Path) -- directory to save resized images in new subdirectories
    """
    for p in img_dir.iterdir():
        if p.is_dir():
            make_directory(out_dir / p.name)
            resize_subdirectory(p, out_dir / p.name)
Example #3
0
def save_linux(message, file_name=None, **kwargs):
    # For Linux-Ubuntu with eSpeak installed:
    # espeak {message} --stdout > {file_name.wav}
    ext = get_platform_audio_ext()

    if not file_name:
        save_dir = repository_root / 'data' / 'audio' / 'untitled'
        make_directory(save_dir)
        file_name = localtime_filepath(save_dir, ext)

    if not has_extension(file_name, ext):
        file_name = add_extension(file_name, ext)

    subprocess.run(['espeak', message, '-w', file_name])
Example #4
0
    def _download_images(self):
        """download images whose links are in the link file"""
        # iterate through keywords
        for keyword in self.supplemented_keywords:
            sk_img_dir = self._define_supp_img_dir(keyword)
            make_directory(sk_img_dir)

            self.img_path = 0

            self._download_image_from_keyword(keyword)

            downloaded_num = len(os.listdir(sk_img_dir))
            print(f"\nSuccessfully downloaded {downloaded_num} images "
                  f"for search '{self.main_keyword + ' ' + keyword}'.\n")
Example #5
0
def save_mac(message=None, file=None, voice='Alex', rate=200, file_name=None):
    if not (message or file):
        raise ValueError('Must specify either message or file')

    if message and file:
        raise ValueError('Can only specify one of either message or file')

    ext = get_platform_audio_ext()

    if not file_name:
        save_dir = repository_root / 'data' / 'audio' / 'untitled'
        make_directory(save_dir)
        file_name = localtime_filepath(save_dir, ext)

    if not has_extension(file_name, ext):
        file_name = add_extension(file_name, ext)

    args = ['say', '-v', voice, '-r', str(rate), '-o', file_name]
    if file:
        args.extend(['-f', file])
    else:
        args.append(message)

    subprocess.run(args)
Example #6
0
 def make_narration(self, audio_dir):
     make_directory(audio_dir)
     for script_section in self.script:
         self._narrate_section(script_section, audio_dir)
Example #7
0
 def setUp(self):
     self.audio_dir = repository_root / 'tests' / 'data' / 'audio'
     make_directory(self.audio_dir)
Example #8
0
 def _create_directories(self):
     make_directory(self.url_dir)