Yeah for M1 Macs the script should be
/opt/homebrew/Cellar/speedtest-cli/$(ls /opt/homebrew/Cellar/speedtest-cli | grep "." | sort -V -r | head -n 1)/bin/speedtest | grep "Download\|Upload"
I don't know shell well enough to fix it with a check in terminal for processor. Sorry.