示例#1
0
def convert_video_to_audio(file_name):
    """Converts mp4 to flac file"""
    abs_path = os.path.dirname(file_name)
    op_name = os.path.basename(file_name) + ".flac"
    logger.info("Convertion started: " + file_name)
    cmd = cmd_for_mp4_to_flac(file_name, os.path.join(abs_path, op_name))
    run_command(cmd)
    logger.info("Done converting: " + file_name)
示例#2
0
def create_srt(srcpath):
    """
    Create srt
    """
    cmd = 'python /Deepspeech/create_srt.py --srcpath ' + srcpath
    logger.debug('Built cmd: ' + cmd)
    return run_command(cmd)
示例#3
0
def split_on_silence(srcpath):
    """
    Split on silence
    """
    cmd = 'python /Deepspeech/split_on_silence.py --srcpath ' + srcpath
    logger.debug('Built cmd: ' + cmd)
    return run_command(cmd)
示例#4
0
def mp4_to_flac(srcpath):
    """
    Convert mp4 files to flac
    """
    cmd = 'python /Deepspeech/mp4_to_flac.py --srcpath ' + srcpath
    logger.debug('Built cmd: ' + cmd)
    return run_command(cmd)
示例#5
0
def download_youtube_video(videoid, dest_path):
    """
    Download the video
    """
    cmd = 'python /Deepspeech/download_from_youtube.py --videoid '+videoid\
            +' --dest_path ' + dest_path
    logger.debug('Built cmd: ' + cmd)
    return run_command(cmd)
示例#6
0
def download_video(destpath, videoid):
    """
    Download the video with youtube videoid
    """
    try:
        op_path = os.path.join(destpath, videoid)
        if not os.path.exists(op_path):
            os.makedirs(op_path)
        cmd = 'youtube-dl' + " -o '" + os.path.join(op_path, videoid) +\
                ".%(ext)s' -f mp4 --write-sub --sub-lang 'en' --convert-subs " + \
                "srt --write-auto-sub --write-info-json --prefer-ffmpeg " + \
                "https://www.youtube.com/watch?v=" + videoid
        logger.debug('Built cmd: ' + cmd)
        run_command(cmd)
        logger.info('Video {} downloaded successfully'.format(videoid))
    except DownloadError as e:
        logger.exception(e)
        logger.error("Could not download the following videos:")
        logger.error(videoid)
        sys.exit(-1)
示例#7
0
def stt(srcpath):
    """
    Deep Speech
    """
    cmd = "CUDA_VISIBLE_DEVICES=0 python /Deepspeech/ds2_stt.py --trainer_count 1 "+\
    "--num_conv_layers=2 --num_rnn_layers=3 --rnn_layer_size=1024 "+\
    "--use_gru=True --share_rnn_weights=False --specgram_type='linear' "+\
    "--mean_std_path=/Deepspeech/mean_std.npz "+\
    "--vocab_path=/Deepspeech/vocab.txt "+\
    "--lang_model_path=/Deepspeech/common_crawl_00.prune01111.trie.klm "+\
    "--model_path=/Deepspeech/params.tar.gz "+\
    "--manifest_path="+srcpath+"/manifest.txt "+\
    "--src_path=" + srcpath
    logger.debug('Built cmd: ' + cmd)
    return run_command(cmd)