Skip to content

Instantly share code, notes, and snippets.

View deepwilson's full-sized avatar
🏠
Working from home

Deep Wilson deepwilson

🏠
Working from home
View GitHub Profile
@deepwilson
deepwilson / get_duration.py
Last active October 20, 2018 06:48
Get duration of a video using 'ffprobe'
from subprocess import check_output
import re
file_name = "movie.mp4"
#For Windows
a = str(check_output('ffprobe -i "'+file_name+'" 2>&1 |findstr "Duration"',shell=True))
#For Linux
#a = str(check_output('ffprobe -i "'+file_name+'" 2>&1 |grep "Duration"',shell=True)) a = a.split(",")[0].split("Duration:")[1].strip()
@deepwilson
deepwilson / get_timestamp_ist
Last active February 8, 2019 08:29
Get current timestamp in IST
# Python3
from datetime import datetime
from pytz import timezone
curent_timestamp_ist = int(datetime.now(timezone('Asia/Kolkata')).timestamp())
# Convert to HH:M:SS
import time
curent_timestamp_ist += 19800
time.strftime("%H:%M:%S", time.gmtime(curent_timestamp_ist))
Using the git reflog command to identify the last-known-good state of your repo
Then, git reset --hard <commit> to revert back to it
Then, another git push --force to reset the remote repository back to that state
"https://community.atlassian.com/t5/Sourcetree-questions/GitHub-repo-lost-much-history-after-forced-push-how-to-restore/qaq-p/254183"
directory = r"C:\Users\deep1\audio_segments/"
files_concat = ["audio_136","audio_062","audio_008","audio_009","audio_045","audio_050","audio_055","audio_114"]
ffmpeg_command = "ffmpeg -i \"concat:"
for file in files_concat:
ffmpeg_command += file+".mp3|"
ffmpeg_command = ffmpeg_command.rstrip("|")
ffmpeg_command = ffmpeg_command+"\" music_concat.mp3"
os.system(ffmpeg_command)
files = []
files = sorted(files , key = lambda x:x.split("_")[-1].replace(".ts",""))
import os
def convert_to_mp3(file,source_dir = "",dest_dir = "",reduce_noise = False):
"""Converts file to mp3
Creates source_dir if required
Returns ffmpeg exit code"""
file_ext = file.split(".")[-1]
if not os.path.isdir(dest_dir):
os.mkdir(dest_dir)
from subprocess import check_output
import sys
import os
def rough_frequency_check(file):
freq = str(check_output('sox \"' +file+ '\" -n stat 2>&1 |findstr "Rough frequency" ',shell=True)) #Windows
# RMS = str(check_output('sox \"' +file+ '\" -n stat 2>&1 |grep "RMS" ',shell=True)) #ubuntu
freq=freq.split(":")[1]
freq=freq.split("\\")[0]
freq=int(freq)
# freq=round(freq,5)
@deepwilson
deepwilson / Scrape "awesome repos" for ArXiv papers to send to Kindle
Created October 28, 2020 14:46
Download ArXiv papers from "awesome" repos related to DL and CV
'''Modified from Source -----> "https://github.com/jyguo1729/web-scraping-for-PDF-file" '''
import requests
from bs4 import BeautifulSoup
def get_title(url):
# url = 'https://arxiv.org/abs/1108.3525'
html = requests.get(url)
soup = BeautifulSoup(html.text,'html.parser')
title = soup.select_one('h1.title.mathjax').text.replace('Title:', '')
return title
from tqdm.notebook import tqdm
import os
# TF Records
dest_path = './tf_records_of_images.tfrecords'
file_writer = tf.io.TFRecordWriter(dest_path)
# source dir