Bluetooth speaker connects as headset and there is no option for AD2P

My bluetooth speaker always connects as a headset so the sound quality is awful and there is no option to switch it to AD2P. My bluetooth headphones connect normally as AD2P, and I connected the problematic speaker to another machine running Gnome and it connects as AD2P. How can I fix it?

You will have to do some modifications yourself. See here: