Skip to content

Instantly share code, notes, and snippets.

import cv2
import mediapipe as mp
mp_drawing = mp.solutions.drawing_utils
mp_drawing_styles = mp.solutions.drawing_styles
mp_face_mesh = mp.solutions.face_mesh
time_start = 0
drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)
cap = cv2.VideoCapture(1)
with mp_face_mesh.FaceMesh(
max_num_faces=1,
import tempfile
import json
import subprocess
import ffmpy
import gradio as gr
include_audio = False
def ffprobe_info(filepath):
ff = ffmpy.FFprobe(inputs={filepath: None}, global_options='-v quiet -print_format json -show_format -show_streams')
from nltk.tokenize import TweetTokenizer
from emoji import demojize
import re
tokenizer = TweetTokenizer()
def normalizeToken(token):
lowercased_token = token.lower()
if token.startswith("@"):
@MandarGogate
MandarGogate / convert_16000.sh
Created February 6, 2018 13:29
Convert all audio files to 16000Hz
#!/bin/bash
for name in *.wav; do
ffmpeg -i "$name" -ar 16000 "16KHz/${name%.*}.wav"
done
@MandarGogate
MandarGogate / benchmark.py
Created October 23, 2017 20:57
Intel® Distribution for Python Benchmark
import time;
import scipy as sp;
import scipy.linalg as la;
import numpy as np;
n=10000
A=sp.random.rand(n,n)
B=sp.random.rand(n,n)
t=time.time()
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 1.
1,"['REALLY+POSS:i', 'ROLLER-SKATE', 'MUSIC++GROUP/TOGETHER', 'LOTION', 'THROW-AWAY', 'PULSATE', 'CENT+ONE', 'BEE', 'SECOND-IN-LIST_2', 'ROPE', 'BATH+DRESS/CLOTHES', 'ns-FORT-WORTH-DALLAS', 'GIRL+CORRECT+LAW', 'FLIP-OVER', 'fs-GRAVITY', 'TABLE', '(1h)HAPPY+(1h)MOST', 'SEAT-BELT', 'NOTICE', 'CALCULATOR', 'THREE_2+HOUR', 'SIGN+LANGUAGE', 'SUNSHINE', 'LITTLE', 'FEATHER', 'ns-ECUADOR', 'CAR+TRUNK', 'APPROVE/VETO', 'NINE-MONTHS', 'ALWAYS+FOREVER_2', 'PRESBYTERIAN', 'MORE-THAN', 'BACKSTAB', 'DISAGREE', 'TELESCOPE', 'PERSON', 'ns-fs-COKE', 'PURSE', 'TIME', '(G)THANKSGIVING', 'GLASSES_2', 'AGENT', 'ns-FORT-WORTH', 'TRIM', 'NOON', 'CLIMB', 'NEXT-WEEK_2', 'SLEEP+DRESS/CLOTHES', '(1h)SCREAM', 'fs-JEWELRY', 'SKYSCRAPER', 'ns-fs-BEIJING', 'STRAWBERRY', '(1h)HAMMER+AGENT', 'TURN+SISTER', 'PICKLE', 'SHORT-SLEEVE', 'SIGN', 'TRIM-HEDGE', 'ASTONISHED', 'MAGNET_3', 'MAGNET_2', 'SCOUT', 'FASCINATE', 'fs-HOLY', 'NECK', 'TWENTY-FIVE', 'NOSE+OPPOSITE', 'FOURTH-PLACE', 'PRESS-BUTTONS', 'fs-FEET', 'MAKE-BUBBLES', 'fs-JELLY', 'SIX-DOL
@MandarGogate
MandarGogate / youtube-dl.sh
Created April 3, 2017 18:18
Youtube-dl custom format download
youtube-dl -F http://www.youtube.com/watch?v=3JZ_D3ELwOQ
output:
[youtube] Setting language
[youtube] 3JZ_D3ELwOQ: Downloading webpage
[youtube] 3JZ_D3ELwOQ: Downloading video info webpage
[youtube] 3JZ_D3ELwOQ: Extracting video information
[info] Available formats for 3JZ_D3ELwOQ:
format code extension resolution note
171 webm audio only DASH webm audio , audio@ 48k (worst)
@MandarGogate
MandarGogate / convertaudio.sh
Created April 3, 2017 18:17
Convert audio files using ffmpeg
ffmpeg -i input.mp4 output.mp3
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3
@MandarGogate
MandarGogate / ffmpeg.sh
Created April 3, 2017 18:15
How to find frames per second of any video file?
ffmpeg -i filename
#Input #0, matroska,webm, from 'somerandom.mkv':
# Duration: 01:16:10.90, start: 0.000000, bitrate: N/A
# Stream #0.0: Video: h264 (High), yuv420p, 720x344 [PAR 1:1 DAR 90:43], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
# Stream #0.1: Audio: aac, 48000 Hz, stereo, s16 (default)
@MandarGogate
MandarGogate / bash.sh
Last active March 14, 2022 11:23
How to convert any mp3 file to .wav 16khz mono 16bit
ffmpeg -i 111.mp3 -acodec pcm_s16le -ac 1 -ar 16000 out.wav