Skip to content

Instantly share code, notes, and snippets.

View vijinho's full-sized avatar

Vijay vijinho

  • England
View GitHub Profile
@vijinho
vijinho / ia-mount.sh
Created January 8, 2025 01:27
Folder mounting tool for Internet Archive archive.org items using rclone, making access to IA items transparent to the filesystem
#!/bin/bash
# Internet Archive File Mounting Tool
usage() {
echo "Usage:"
echo "1. Create a file with the archive.org ID (e.g., 'test.ia' for https://archive.org/details/test)."
echo "2. Run this script."
echo "It will mount each '.ia' file, list its contents, and append directory information to the corresponding file."
}
@vijinho
vijinho / text_to_speech.sh
Created January 7, 2025 16:25
Wrapper for TTS https://github.com/coqui-ai/TTS that takes model and vocoder ids and outputs a wav or mp3
#!/bin/bash
# Associative arrays for mapping IDs to model and vocoder names
declare -A model_ids=(
[12]="tts_models/en/ljspeech/tacotron2-DDC_ph"
[15]="tts_models/en/ljspeech/tacotron2-DCA"
)
declare -A vocoder_ids=(
[4]="vocoder_models/en/ljspeech/multiband-melgan"
@vijinho
vijinho / say-fortune.sh
Last active January 7, 2025 16:07
TTS example script for Coqui-AI https://github.com/coqui-ai/TTS which speaks-out a fortune, for testing models and vocoders
#!/bin/bash
# requires https://github.com/coqui-ai/TTS
# Associative arrays for mapping IDs to model and vocoder names
declare -A model_ids=(
[11]="tts_models/en/ljspeech/tacotron2-DDC"
[12]="tts_models/en/ljspeech/tacotron2-DDC_ph"
[15]="tts_models/en/ljspeech/tacotron2-DCA"
[20]="tts_models/en/ljspeech/neural_hmm"
@vijinho
vijinho / text_to_wav.sh
Last active January 7, 2025 11:24
Uses mimic https://github.com/MycroftAI/mimic1?tab=readme-ov-file to speak text or output wav or mp3 file
#!/bin/bash
# Uses mimic https://github.com/MycroftAI/mimic1?tab=readme-ov-file to speak
# optionally uses aplay https://linux.die.net/man/1/aplay to speak then delete the output file
# Set default values
VOICE='slt_hts'
WAVFILE="$TEMP/$(date "+%Y%m%d.%H%M%S")-tts.wav"
TEXT=''
TEXTFILE=''
@vijinho
vijinho / url_final.sh
Created January 6, 2025 12:53
bash script to follow a given url to its final destination, i.e. to unshorten URLs or follow-through redirects to the ultimate destination URL
#!/bin/bash
# Function to parse command line arguments
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
-u=*|--url=*)
URL="${1#*=}"
shift # past argument=value
;;
@vijinho
vijinho / transliterate-file.sh
Created January 6, 2025 10:07
bash shell script to transliterate a file - that is, to strip any accents from the file and make it standard English alphabetic characters
#!/bin/bash
# Parse command-line options
while getopts ":f:" opt; do
case ${opt} in
f)
file=$OPTARG
;;
\?)
@vijinho
vijinho / generate-subtitles.sh
Last active January 7, 2025 09:31
A bash script to check a folder for media (video/audio) files and transcribe them using 'whisper' (working) or 'whisper-clli' (TBD later) by detecting if there exists a .srt file already
#!/bin/bash
# NOTE this is actually using whisper-wrapper.sh: https://gist.github.com/vijinho/ad9bd80c990a803efef7f96ae3e7ee98
# Function to display usage information
usage() {
echo "Usage: $0 [-m | --media-directory <directory>] [-a | --transcription-args \"<arguments>\"]"
echo "Defaults: -m `pwd`"
exit 1
}
@vijinho
vijinho / whisper-wrapper.sh
Last active January 8, 2025 12:48
wrapper for https://github.com/ggerganov/whisper.cpp whisper.cpp to generate transcriptions from given input media file
#!/bin/bash
# Default values
MODEL="$HOME/src/whisper.cpp/models/ggml-large-v3-turbo-q5_0.bin"
INPUT_FILE=""
OUTPUT_FILE="$TEMP/whisper-$(date "+%Y%m%d%H%M%S").wav"
WHISPER_ARGS="-m $MODEL -l en -t 12 -pp -pc -otxt -ovtt -osrt"
# Function to display usage information
usage() {
@vijinho
vijinho / dav.sh
Last active July 22, 2024 19:26
Simple dav server using rclone with a htpasswd file, specify port and data dir, designed for home network usage only. e.g. dav.sh 8080 /mnt/data/joplin - serves webdav using .htpasswd file in folder joplin - can be run from crontab using @reboot
# ./dav.sh 8090 /mnt/data/joplin
PORT=$1
DATA_DIR=$2
NAME=`basename $DATA_DIR`
CACHE_DIR=/var/cache/dav/$NAME
#rm -fR $CACHE_DIR
mkdir -p $CACHE_DIR
chmod -fR 777 $CACHE_DIR
/home/linuxbrew/.linuxbrew/bin/rclone serve webdav --htpasswd $DATA_DIR/.htpasswd --addr :$PORT $DATA_DIR --buffer-size 512M --dir-cache-time 15m --cache-dir $CACHE_DIR --vfs-cache-mode full --vfs-cache-max-size 4G --no-checksum --vfs-case-insensitive --vfs-disk-space-total-size 4G 2>&1 > /var/log/rclone.log &
exit 0
@vijinho
vijinho / dav-simple.sh
Last active July 22, 2024 19:26
Simple insecure local dav server using rclone - specify port and data dir, dirname used as user/pass, e.g. dav.sh 8080 /mnt/data/joplin/
# ./dav.sh 8090 /mnt/data/joplin
PORT=$1
DATA_DIR=$2
NAME=`basename $DATA_DIR`
CACHE_DIR=/var/cache/dav/$NAME
#rm -fR $CACHE_DIR
mkdir -p $CACHE_DIR
chmod -fR 777 $CACHE_DIR
/home/linuxbrew/.linuxbrew/bin/rclone serve webdav --user $NAME --pass $NAME --addr :$PORT $DATA_DIR --buffer-size 512M --dir-cache-time 15m --cache-dir $CACHE_DIR --vfs-cache-mode full --vfs-cache-max-size 4G --vfs-cache-max-size 1G --no-checksum --vfs-case-insensitive --vfs-disk-space-total-size 4G 2>&1 > /var/log/rclone.log &
exit 0