Wagner Lipnharski says:

A ringing detection, and audio coupling circuit can be done easily: When a ring comes, the AC signal 60V 20Hz feeds the opto-coupler LED and the -RING signal goes to ground, the microcontroller senses it and drives the relay that closes and connects the 600 Ohms phone transformer to the line. For most applications, the ringing sensing circuit (capacitor, zeners, ...) does not interfere so much in the common phone line usage for voice or data, if still connected in parallel. If you want, you can use a SPDT relay and switch the phone line *from* the ringing sensing circuit to the phone transformer, but it is not strictly necessary. Of course there are circuits that can do all of the below easily, but as usual, at cost of more dollars.
phone line
o---------o--------------------o    o-------------.    
          |                    ------             |     .-----> 
         ---  0.22µFx250V      relay              |     |
         ---  0.47µFx250V                         'S | S'
          |                             600 Ohms   S | S  600 Ohms
          |                                        S | S
          V  Zener 22V                            .S | S.
         ---                                      |     |
          |                                       |     '----->
         ---                        o +5V         |
          A  Zener 22V              |             |
          |                         |             | 
          |                         R 10 kOhms    |
 2 kOhms  R                         R             |
          R                         |             |
          |         opto coupler    |             |
          o-------.   4N35  .-------o---->        |
          |       |         |          -RING      |
         ---      V __--> |/                      | 
  1N4007  A      ---      |\e-.                   |
          |       |           |                   |
          o-------'           |                   |
          |                  GND                  |
          |                                       |
o---------o---------------------------------------'
phone line

Code: