There are special purpose (and relatively expensive) optical isolators available with separate feedback connections designed for high analog linearity and fidelity but, for non-critical AC applications, a standard opto isolator may be adequate if it is driven by a current source instead of a voltage. This eliminates the non-linear LED input voltage to current relationship, with the opto isolator output current typically being quite linear with respect to the input current, especially for low current levels.
Below is the LTspice simulation of such a circuit using the 4N25, a common and representative general purpose opto isolator.
(Ocom is the isolated output common and Rsim is just to allow the simulation to run with an isolated output ground).
Op amp U3 is configured as a current driver for the opto input, generating a current proportional to the voltage input.
The opto is operated Class A with about 1 mA DC bias current.
Op amp U5 is a buffer/non-inverting amplifier that amplifies the voltage across R2 to convert the opto isolator output current back to a voltage.
If you have a high impedance load (>>1.5KΩ) and are satisfied with an output voltage of about 1/2 the input (depending upon the opto transfer gain), then U5 may not be needed and you can use the voltage across R2 as the output.
R2 can be increased in value to increase the output voltage in this configuration, the tradeoff being some increase in the distortion.
If a symmetrical output signal with respect to ground is required, then the output can be capacitively coupled to a load resistor connected to Ocom.
As can be seen, the output voltage plot appears quite linear with respect to the input. (Note the blue trace where the output is graphically superimposed over the input so any non-linearities are more readily observed).
The simulation results are somewhat idealized of course, as determined by the accuracy of the models, and the real linearity will depend upon the actual characteristics of the opto coupler used, but should still be good, adequate for non-critical voice and music applications.
The linearity degrades at higher operating currents due to reduction in the CTR of the opto but looks good if the maximum current is kept to no more than a couple mA or so (1.6mA maximum in this simulation).
The simulated harmonic distortion is less than 1% at 1kHz for a 1 Vrms input, and the frequency response is 20Hz to 20kHz.
Distortion doesn't quite meet high fidelity standards but should be inaudible in most audio applications (except perhaps to those with the proverbial "Golden Ear").
(A double-blind A/B listening test of music would be interesting).
Pot U2 adjusts to get the desired voltage output and compensate for the gain of the particular opto isolator you have.
The opamps shown are rail-rail types but standard types could be used if dual supply voltages are available.
Any op amp type used should have good performance (noise, bandwidth, distortion) over the audio range. Thus common op amps, such as the 741 and LM324, will likely give poorer performance in this circuit due to their high noise and distortion.
Audio Isolation With Standard Optical Isolator
Current Drive Improves Standard Optical Isolator Linarity For AC Audio Frequency Applications