I've managed to solve this by adding a few delays, but the main fix was adding a space after setting the volume since in some languages or settings, the apostrof isn't automatically set, only when a character or space is followed by it.
So here is my adaptation, probably smaller delays would still work:
DELAY 1000
GUI SPACE
DELAY 2000
STRING terminal
DELAY 500
ENTER
DELAY 1000
STRING osascript -e 'set volume 7'
DELAY 500
SPACE
DELAY 500
ENTER
DELAY 500
STRING open
DELAY 500
ENTER