Skip to content

Instantly share code, notes, and snippets.

View ecovictoriano's full-sized avatar

Victoriano Eco ecovictoriano

View GitHub Profile

AWS Community Day PH Initiative

  • When: September (tentative)
  • Where: To be announced
  • Pre-registration link: bit.ly/AWS2019

What is AWS Community Day?

AWS Community Days are community-organized cloud education events, featuring technical discussions and demos led by expert AWS users and industry leaders from around the world.

What to expect from AWS Community Day?

  • Renew, Revive & Revitalize to exemplify your excitement about the work you do
def shell_exec(cmd, cb=None, poll=True):
"""execute a shell command
cmd=str command to execute
cb=<callable> callable function
poll=True whether to poll for updates"""
with Popen(cmd, stdout=PIPE, bufsize=1) as p:
if poll:
@ecovictoriano
ecovictoriano / shell_exec.py
Created March 6, 2018 20:47
Execute shell commands and get stdout message for long running commands with polling
from subprocess import Popen, PIPE
def shell_exec(cmd, cb=None, poll=True):
with Popen(cmd, stdout=PIPE, bufsize=1) as p:
if poll:
while p.poll() is None:
line = p.stdout.readline().decode('utf-8').strip()
if callable(cb): cb(line)
time.sleep(0.5)
@ecovictoriano
ecovictoriano / README.md
Created March 6, 2018 14:28
Python singleton

Python Singleton

Here is how to implement singletons in Python

Taken from: https://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons

@ecovictoriano
ecovictoriano / python-gcp-stt.md
Created December 28, 2017 00:46
Transcribe audio file to text (speech-to-text) using Google Cloud Platform's Speech API

Transcribe audio file to text (speech-to-text) using Google Cloud Platform's Speech API

Convert audio to text using GCP Speech API

Requirements

pip install --upgrade google-cloud-speech

Export the GCP credential env and execute the request

#!/bin/bash
@ecovictoriano
ecovictoriano / python-watson-stt.md
Last active December 28, 2017 00:47
Transcribe audio file to text (speech-to-text) using IBM's Watson SpeechToText API
@ecovictoriano
ecovictoriano / shell-ffmpeg-mp3-to-wav.sh
Created December 27, 2017 23:49
Convert MP3 to WAV using FFMPEG
ffmpeg -i AUDIOFILE.mp3 -c:a pcm_s16le AUDIOFILE_OUTPUT.wav
# we can add:
# -ac 1 to convert to mono
# -ar 16000 to convert to 16000 sample rate
@ecovictoriano
ecovictoriano / python-folders-exists.py
Last active December 28, 2017 00:51
Create folders/directories if not exists
# assuming we're inside "/a/b/c/d" directory
if not os.path.exists('./x/y/z'):
os.makedirs('./x/y/z')
# this will create the folders "x", "y", and "z"
"""
.
|-- a
| `-- b
| `-- c
@ecovictoriano
ecovictoriano / python-ffmpeg-waveform.md
Last active February 27, 2023 20:19
Generate waveform image from audio file using FFMPEG

Generate waveform image from audio file using FFMPEG

This will generate waveform images (jpg) for all files inside media/audios and media/videos to a directory media/waveforms following the sufolder structure of media

Folder structure

Audio/video folder structure

|-- media
|   |-- audios
|   |-- videos