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.