<commit_before>#! /bin/sh

# First variable: audio capturing device hardware number
HW="$1"

# Second Variable: sampling duration in seconds
DURATION="$2"

# Third variable: folder PATH where to store the recording
DIR="$3"
cd ${DIR}

BASE=sample
i=0
if [ -e ${BASE}-${i}.wav ] ; then
    i=1
    while [ -e ${BASE}-${i}.wav ] ; do
        i=$((i+1))
    done
fi
NAME=${BASE}-${i}

do_record () {
    # record
    arecord -f cd -r 48000 -D hw:${HW} -d "$1" ${DIR}${NAME}.wav
}

do_stream () {
    # stream to audio output
    arecord -D plughw:1,0 -f dat | aplay -f dat
}

do_label() {
    # add default label to last recorded file
    echo "${NAME},default">>${DIR}labels.csv
}

do_record ${DURATION}
do_label<commit_msg>microphone script: substitute d incremental counter with a temporal timestamp<commit_after>#! /bin/sh

# First variable: audio capturing device hardware number
HW="$1"

# Second Variable: sampling duration in seconds
DURATION="$2"

# Third variable: folder PATH where to store the recording
DIR="$3"
cd ${DIR}

BASE=sample
# Timestamp is year-mount-day-hour+minute+second
TIMESTAMP=$(date "+%Y-%m-%d-%H%M%S")
NAME=${BASE}-${TIMESTAMP}

do_record () {
    # record
    arecord -f cd -r 48000 -D hw:${HW} -d "$1" ${DIR}${NAME}.wav
}

do_stream () {
    # stream to audio output
    arecord -D plughw:1,0 -f dat | aplay -f dat
}

do_label() {
    # add default label to last recorded file
    echo "${NAME},default">>${DIR}labels.csv
}

do_record ${DURATION}
do_label
{'fraction_non_alphanumeric': 0.1601615074024226, 'fraction_numerical': 0.016823687752355317, 'mean_word_length': 3.632398753894081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4589683', 'n_tokens_mistral': 548, 'n_tokens_neox': 529, 'n_words': 164}