Terminal command to switch between JST output and Headphone jack?

I’m using https://wiki.seeedstudio.com/ReSpeaker_2_Mics_Pi_HAT/ From the raspberry pi GUI, I can select between to output from the JST speaker output or headphones (when plugged in) I’m wondering if anyone knows of a good way to make that selection via the terminal. The reason being is I want to have a speaker plugged in and use the line out at the same time and be able to switch between the two. I can do this manually by unplugging and plugging in the headphone jack, as well as from the GUI, but I would like to be able to do it programmatically with python. possible?