Linux / macOS - Way to encode mp3's from folder to taf file

after i gave up to execute teddy with wine or mono i found a way to encode all mp3 files from a directory and encode it to a taf-file.

i created an alias:

mp3_taf() {
    local TMPFILE=$(mktemp -p /tmp)

    mkdir -p ${HOME}/tmp/teddycloud/data/content
    mkdir -p ${HOME}/tmp/teddycloud/data/library
    mkdir -p ${HOME}/tmp/teddycloud/certs/server
    mkdir -p ${HOME}/tmp/teddycloud/certs/client
    mkdir -p ${HOME}/tmp/teddycloud/config
    # LIST=`python -c 'import glob; print("|".join(sorted(glob.glob("*.mp3"))))'`
    # ffmpeg -i "concat:${LIST}" -acodec copy ${TMPFILE}
    # find . -maxdepth 1 -iname '*.mp3' -print0 | sort -z | xargs -0 mp3wrap ${TMPFILE}
    # cat *.mp3 ${TMPFILE}
    find . -name "*.mp3" -type f -exec cat {} >> ${TMPFILE} \; 
    docker run --rm \
        -v /tmp:/tmp:ro \
        -v "${PWD}:/app" \
        -v "${HOME}/tmp/teddycloud/data/content:/teddycloud/data/content" \
        -v "${HOME}/tmp/teddycloud/data/library:/teddycloud/data/library" \
        -v "${HOME}/tmp/teddycloud/data/firmware:/teddycloud/data/firmware" \
        -v "${HOME}/tmp/teddycloud/certs:/teddycloud/certs" \
        -v "${HOME}/tmp/teddycloud/config:/teddycloud/config" \
        --workdir /teddycloud \
        --entrypoint teddycloud \ \
        ENCODE ${TMPFILE} /app/500304E0

        rm -f ${TMPFILE}

just execute the alias in the related directory with your mp3’s and upload taf file via teddycloud.

Unfortunately, the certificates are recreated every time the container is started, so I had to create the volumes to store them

This is confusing. Why would you need stable certificates for the encoding of the audio?

Oh, and works just fine afaict.

I also wanted to just create the Opus file and manage the folders and IDs on my microSD card by myself.
And the most comfortable way for me, using a MacBook with macOS, was a quick action I can fire directly on a folder in Finder. So I used Automator and the Python script linked here:

Since Python is not the language of my choice, the setup was a little fiddly.
At first you need to add a Python environment, install protobuf and ffmpeg, and maybe other missing libs too. It took me forever.

Then update your with the new one given by SciLor in this issue:

For the main Python script I created another optional argument ‘–save-in-source-folder’, add it after line 1027:

parser.add_argument('--save-in-source-folder', action='store_true', help='Saves the file directly in the given source folder with filename 500304E0')

And the handling of the new argument some lines underneath:

if args.save_in_source_folder:
    out_filename = os.path.join(args.input_filename, "500304E0")

If you start the script from the quick action menu (with the new argument) like in the screenshot below, it creates the opus file directly in the folder.

For setting up the quick action, start Automator and create a new workflow which runs a shell script. The input is a folder in Finder and hte content of the shell-script is (see screenshot below):

export PATH=/opt/homebrew/bin:$PATH

source /Users/YOURUSER/Toniebox/opus2tonie-main/venv/bin/activate

python3 /Users/YOURUSER/Toniebox/opus2tonie-main/ --save-in-source-folder "$@" > /Users/YOURUSER/Toniebox/opus2tonie-main/log.txt 2>&1

And this is all the magic.
I guess the setup is probably not perfekt, but it works for me.
But if you encounter any problems, I might not help, sorry.

Cause he uses the teddycloud image for doing his conversation:
See his code here:

docker run --rm

Package teddycloud · GitHub
ENCODE ${TMPFILE} /app/500304E0