To use the speaker output for transmission, you need to amplify the low power AC signal to a normal digital signal level in order to use it. The following circuit is an example:
But to actually send or receive as IR or RF you also need additional interfaces. Fortunatly, building these interfaces is not very hard. You can do it by modifying existing devices or by using special built devices. Here are a few examples of devices I and some other users have built.
Using a Nexa remote control as generic 433.92MHz transmitter
A generic 433.92MHz transmitter using an Auriel device by Walter Krämbring
A generic high power 433.92MHz transceiver using an Auriel devices by Walter Krämbring