Skip to content

Instantly share code, notes, and snippets.

@simlated
simlated / mp3-inmemory-duration.py
Last active February 29, 2024 20:48
Get duration of an mp3 generated by Elevelabs API
import requests
from mutagen.mp3 import MP3
from io import BytesIO
# Your API key (replace <mykey> with your actual API key)
api_key = <mykey>
# Replace <voiceid> with your actual voice id value
voice_id=123456
url = f"https://api.elevenlabs.io/v1/text-to-speech/f{voice_id}"
@simlated
simlated / recursive-folder-mp4-duration-csv.sh
Last active August 8, 2022 15:31
Print csv with name of mp4 files recursively found in folder and their duration calculated with ffprobe (you need it installed)
find . -type f -name "*.mp4" -exec printf "%s," {} \; -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \;
@simlated
simlated / remove-s3-objects-by-date.sh
Last active May 6, 2024 15:03
Remove objects from an AWS s3 bucket if last modified date is egual or before a given date.
#!/bin/bash
# usage: ./remove-s3-objects-by-date.sh bucket_name min_date
# min_date parameter must be in YYYY-MM-DD format
if [ "$1" = "" ]; then
echo "Missing bucket name. Usage:./remove-s3-objects-by-date.sh bucket_name min_date"
exit 1
fi
if [ "$2" = "" ]; then