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
Audio/video folder structure
|-- media
| |-- audios
| |-- videos
# 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 |
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 |
Convert audio to text using IBM Watson SpeechToText API.
API Reference: https://www.ibm.com/watson/developercloud/speech-to-text/api/v1/?curl#introduction
Each JSON result is stored on a separate file. Results are aggregated in a CSV file.
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) | |
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: |
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.