Computer audio interface to wire-based telephone network
Colin Fahey
phone_speech_system_custom_circuit.jpg
A computer can make voice telephone calls using any modem and a simple circuit.

1. Introduction

This document describes how to use any conventional modem and a simple circuit to give any personal computer (PC), with any operating system, the ability to place telephone calls that may involve voice interaction.
An ordinary modem is used to activate the telephone wire by going "off hook", and later releasing the telephone wire by going "on hook" ("hang up").
A simple electrical circuit is used to give any audio device, such as a sound card or sound interface of a personal computer (PC), access to the audio signals on a telephone wire.
Thus, a personal computer (PC) can initiate a connection to a telephone number, and then wait for a human or an automated system to answer, and then initiate a conversation based on speech or other sounds.
This document is intended for hobbyists interested in learning a few things about the electrical requirements and protocol for interacting with the Central Office (CO) of a wire connected telephone network in the United States (US).
There are many technologies for allowing people to interact with voice based systems through telephones.
There are many commercial products and services offered to handle everything associated with telephone interaction with a corporate database.
It is quite easy to find hardware to handle many telephone calls to a single number.
Telephony has expanded to the Internet, with protocols like "Voice over Internet Protocol" (VoIP).
Computers anywhere in the Internet can be configured to interact with VoIP through speech recognition and speech synthesis.
These computers can optionally follow voice conversation flowcharts expressed in XML text files (Voice XML).
This document has nothing to do with any of those practical solutions to the problem of automating voice interaction with a business or organization.
This document is intended for the entertainment of hobbyists with small budgets.

2. Disclaimers

Constructing an electronic circuit, and connecting in to a telephone network, involves many risks.
You are responsible for learning about any laws, hazards, and risks that may apply.
The following is a list of some of the issues that you must consider if you are interested in constructing and testing a circuit similar to the one featured in this article:
1. All information about the electrical specifications of the telephone service is only valid in the United States (US).
2. Ringing voltage on telephone wires (90 Volts) can injure people.
Lightning or fallen power wires can lead to voltages on telephone wires that can injure people.
3. You are responsible for any damage to telephone company circuits caused by your use of unauthorized devices in your home or office.
4. Recording telephone conversations without the explicit approval of all parties involved is against the law.
( ...unless you're the government! Otherwise, do as they say, and not as they do! )
5. You are responsible for any damages to your computer caused by connecting your own circuitry to your computer.
6. You cannot sell any product intended for use with a telephone network without approval from the FCC.
This document is only a description of my personal experiences.
You are responsible for learning about laws and risks from authoritative sources.

3. Telephone audio interface circuit

The purpose of the circuit described in this section is to allow conventional audio recording and playback equipment, such as a sound card or audio port on a personal computer (PC), to send and receive audio over a conventional land wire (wired) telephone connection.
The telephone wire and the audio equipment are not directly connected; the coupling is only through transformers.
Both sides of the interface are protected from excessive voltages.
The signals are limited to a range of frequencies (bandwidth) relevant to telephone audio (300 Hz to 3500 Hz).
The circuit has only "passive" components; all driving voltages are external.
The circuit must be used in conjunction with a modem, telephone, or other circuit capable of going "off hook" (bringing the resistance of the wire low enough to indicate to the Central Office (CO) that the wire is in use).
It would be trivial to add an "off hook" aspect to this circuit, but having a circuit at all is already a big obstacle for many hobbyists.
phone_circuit_box01.jpg
Appearance of the assembled circuit
phone_circuit_board02.jpg
Appearance of the circuit board
phone_circuit_schematic.jpg
Schematic of the telephone audio interface circuit
You can build the device almost exactly as it appears above if you make the following investments:
1. Make sure you have basic tools: Screwdrivers, soldering iron, knife;
2. Visit Radio Shack, buying items listed below, for $29 after taxes;
3. Visit any hardware store, buying two nuts, bolts, washers, for $1.
4. Spend about four hours constructing the circuit according to the schematic;
If you do not have experience building electronic circuits, soldering, drilling holes, and making electrical measurements, do not make this your first project!
The only person who should attempt to build this circuit is the person who already knows for sure that he or she can build it!

4. Radio Shack : the ubiquitous electronics store

Radio Shack is a consumer electronics company with stores around the world. The following is a link to their Internet site:
http://www.radioshack.com
On their Internet site a person can find a link named "Electronic Components", which leads to their catalog of electronic components and corresponding documentation.
A person can find prices for parts.
A person can get a list of the nearest store locations, and maps.
Parts can be ordered online.
I have decided to build my simple circuit using Radio Shack parts because this means that anyone else in the world can easily reproduce my work.
Also, any part offered by Radio Shack is practically guaranteed to be available for many years at a low price.
Here is a list of Radio Shack parts I used to build the circuit, with the catalog numbers:
QtyDescriptionSerial #PriceTotal
1Project Enclosure (6"x3"x2") #270-1805$ 3.79$ 3.79
1Surface Mount Modular Jack (RJ11/RJ14) #279-0202$ 4.99$ 4.99
13-Conductor Stereo 1/8th" Phone Jack (Pkg.2) #274-0249$ 2.99$ 2.99
1Component PC Board (71x94mm), 750 holes #276-0158$ 2.99$ 2.99
2Audio Isolation Transformer (1:1) #273-1374$ 3.99$ 5.98
2Metalized-Film Capacitor 1.0uF, 250WVDC #272-1055$ 1.49$ 2.98
12.2K ohm 1/2W 5% Carbon Film Resistor (Pkg.5)#271-1121$ 0.99$ 0.99
21N4733A, 5.1V, 1.0W Zener Diode (Pkg.2) #276-0565$ 0.99$ 1.98
SUBTOTAL: $26.69
TAX:      $ 2.07 (California 7.75% sales tax)
TOTAL:    $28.76

5. Ace Hardware : the not-so-ubiquitous hardware store

I needed bolts, washers, and nuts to fasten a telephone jack to the plastic case of my circuit.
I went to Ace Hardware, but I could have gone to Home Depot, or maybe even a supermarket, to find similar parts.
QtyDescriptionPriceTotal
2Bolt No.8-32 4.2mm-32$ 0.17$ 0.34
2Washer No.8 $ 0.10$ 0.20
2Nuts No.8-32 2" $ 0.10$ 0.20
SUBTOTAL: $0.74
TAX:      $0.06 (California 7.75% sales tax)
TOTAL:    $0.80

6. Tools and accessories

The following table lists some of the items I needed for the construction and use of the circuit:
Soldering iron $ 5.00 (approx)
Solder $ 3.00 (approx)
Precision knife $ 3.99
Wires $ 1.00 (approx)
Telephone extension cord #279-0374 $ 5.79
Male-Male mini-phono 6' extension cord (qty.2)$ 3.00 (approx)
Four-wire 3-way coupler (RJ11/RJ14) #279-0447 $ 4.99

7. Comments on the circuit

I am not an electrical engineer.
I studied various telephone circuits (see references listed near the end of this article), and extracted various elements that would support my own design goals.
If you were really desperate, and risk to your PC was not a factor, you could connect a telephone wire to your sound port using only a pair of capacitors!
That is a very bad idea, because the ringing voltage, and the possible random voltage spikes on the telephone wire, can damage unprotected devices.
The Zener diodes in my circuit short-circuit excessive voltages.
Notice that they are facing opposite directions, so that for a given applied voltage with a given polarity, one Zener diode is poised to conduct current normally, and the other is poised for reverse-breakdown should the voltage exceed its rating (e.g., 5.1 V).
Only when a voltage exceeds the reverse-breakdown voltage of one of the Zener diodes will the pair ultimately allow current to flow, thus short-circuiting the wires to which the pair of diodes is connected.
Note that this works regardless of where the signals originate.
Alternating Current (AC) signals from the telephone wire that are greater then 5.8 Volts ( 5.1 V + 0.7 V ) after passing through the transformer will be clipped.
Direct Current (DC) or Alternating Current (AC) audio signals from an audio source, not the telephone wire, will also be clipped at 5.8 Volts.
So, each party, telephone company and audio equipment, is protected from excessive voltages coming from the other party.
The device is really a pair of identical circuits. Either audio plug can be used for input or output.
Basically, both audio signals are coupled to the single telephone signal.

8. Using a modem to go "off hook"

8.1 The purpose of the modem

The purpose of the modem in this system is to create an electrical condition that the telephone service provider will recognize as a request to become an active participant in the telephone network.
This request is called "going off hook", a reference to the original telephone designs that required a user to lift a speaker or handset off of a hook.
The activation request is almost instantly granted, within a fraction of a second.
Once the wire becomes active, all other aspects of telephony can be conducted through audio signals.
Although transmitting telephone numbers ("dialing") can be done by playing audio files ( *.WAV, *.MP3 ), recorded audio (DAT, audio CD, tape), or software audio synthesis (sin() functions), the modem has the intrinsic ability to perform this function.
However, it should be understood that the only purpose of the modem is requesting activation of the telephone wire.
If a person has an alternative method of simulating the off hook condition (i.e., simply lowering the resistance across the telephone wire), the modem is not required.
However, a modem is a very inexpensive, commonplace, and convenient device for performing this function.
The system described in this article does NOT require a modem with audio recording or playback capability, sometimes called a "voice modem".
However, in another section of this article I discuss the possibility of using a voice modem as an alternative to using a custom electrical circuit.

8.2 Typical modem

I chose to use an external modem manufactured by Hayes called "Accura", a V.92 fax-modem with voicemail capability.
Any modem can be used for the system described in this article.
I wanted an external modem simply because it is easy to attach to any computer, and I can bring it to a friend's house to use with their laptop or desktop computer.
Although it is hardly important, I also considered the possibility that maybe a Basic Stamp 2 computer could use the RS-232 modem.
Caution: Serial ports (RS-232) ports, like PS/2 ports, are being phased out, and USB is the new standard.
An external USB modem can often be accessed by software as if it were a legacy "COM" port device by device drivers that come with the modem.
There is a small USB/RS-232 adapter (~$30) that can be used to connect contemporary laptops and desktop computers to RS-232 devices.
Such an adapter has a corresponding device driver to emulate a legacy serial port interface (e.g., "COM" device).
hayes_modem_box001.jpg
Hayes external modem : box
hayes_external_modem002.jpg
Hayes external modem

8.3 Modem commands

When a modem is first turned on, it enters a state called "command mode".
If the modem successfully connects to a remote modem or remote fax device over the telephone wire, it enters a state called "data mode".
However, the system described in this document will not use the modem to establish a "data mode" connection with a remote device, so the modem will always be in "command mode".
When in command mode, the modem accepts commands in the form of plain ASCII characters.
Characters are exchanged between the modem and the computer over a serial cable, or through a device driver that makes an internal card (e.g., PCI card) accessible as a serial device.
In either case, programs use API calls to access serial devices (e.g., "COM1" or "/dev/modem").
One major subset of modem commands is called "AT" (ay-tee) commands, and these commands all begin with the characters "at" (or "AT").
As modems evolved, the list of commands expanded, offering increasingly esoteric features. The system described in this article only requires the ability to take the modem "off hook" and later return the modem to the "on hook" state. The ability to dial digits, and optionally turn on a speaker for monitoring the call, are useful features, but are not essential. The following table lists the modem commands likely to be used with the system described in this article:
ActionCommand
On-Hook ("Hang Up")ATH [zero] [return]
Off-Hook ("Pick Up")ATH [one] [return]
"Dial" Digits ATDT [digits,#,*] ; [return]
"Dial" Digit ATDT [digit,#,*] ; [return]
Speaker Off ATM [zero] [return]
Speaker On ATM [two] [return]
The following table shows a hypothetical sequence of commands used to place a telephone call, interact with an automated system that uses "touch tones" (DTMF), and then terminate the call ("hang up"):
CommandAction
ATM 2 [return]Speaker On
ATH 1 [return]Off-Hook ("Pick Up")
ATDT 5551212 ; [return]"Dial" 5551212
ATDT 3 ; [return]"Press" 3
ATDT # ; [return]"Press" Pound (#)
ATDT * ; [return]"Press" Star (*)
ATH 0 [return]On-Hook ("Hang Up")
ATM 0 [return]Speaker Off

8.4 AT command set

The "AT command set" is implemented by almost all modems in existence.
This set of commands was originally implemented by Hayes modems.
Most modems are classified as "Hayes compatible" because they implement the set of AT commands.
All AT commands must begin with the AT prefix, followed by a command letter, and ended with the ENTER(*) key.
( *...ENTER, CARRIAGE RETURN, CR, RETURN, '\r', 13, 0xd, Control-M, ^M )
Spaces are allowed in the command string to increase command line readability, but are ignored by the modem during command execution.
All commands may be typed in either upper case or lower case, but never mixed.
A command issued without any parameters is considered as specifying the same command with a parameter of 0 (zero).
The following is a condensed list of AT commands.
A more complete and detailed list can easily be found on the Internet via a search using the keywords "at modem commands".
CmdAction
A Answer incoming call
D 0-9, A-D, # and * (e.g., AT T D 5551212*#)
P Pulse dial
T Tone dial
W Wait for second dial tone
, Pause
@ Wait for 5 secs of silence
! Flash (very brief on-hook)
; Return to command mode after dialing
E0 Command echo disabled
E1 Command echo enabled
F0 Autoscan mode
F1 300 bps connection only
F3 V.23 connection only
F4 1200 bps connection only
F5 2400 bps connection only
F6 4800 bps connection only
F7 7200 bps connection only
F8 9600 bps connection only
F9 12000 bps connection only
F1014400 bps connection only
H0 Modem on-hook (hang up)
H1 Modem off-hook (pick up)
I0 Product code
I1 Checksum code
I2 ROM test
I3 Firmware and device ID
L0 Low speaker volume
L1 Low speaker volume
L2 Medium speaker volume
L3 High speaker volume
M0 Speaker off
M1 Speaker on until carrier detect
M2 Speaker on
M3 Speaker off during dialing, on until carrier detected
N0 Connect only at DTE rate
N1 Auto rate negotiation
O0 Return to data mode
O1 Initiate an equalizer retrain and return to data mode
P Pulse dial
Q0 Result codes enabled
Q1 Result codes disabled
T Tone dial
V0 Numeric responses
V1 Text responses
W0 Report DTE speed only
W1 Report wire speed, error correction protocol, and DTE speed
W2 Report DCE speed only
X0 Hayes Smartmodem 300 compatible responses/blind dialing
X1 Same as X0 plus all CONNECT responses/blind dialing
X2 Same as X1 plus dial tone detection
X3 Same as X1 plus busy signal detection/blind dialing
X4 All responses and dial tone and busy signal detection
Y0 Long space disconnect disabled
Y1 Long space disconnect enabled
Z0 Reset and recall user profile 0

8.5 Testing the modem

This section describes methods for quickly verifying the ability to control a modem connected to the computer.
The first method is suitable for Windows 98/NT/Me/2K/XP.
The basic idea is to start "serial communication" software that can be found in almost any typical installation of the Windows operating system : "HyperTerminal".
Windows 98     : "C:\Program Files\Accessories\HyperTerminal\Hypertrm.exe"
Windows 2000\XP: "C:\Program Files\Windows NT\hypertrm.exe"
( The double-quotes shown above are necessary when making shortcuts or when executing from the command prompt, because the file paths contain spaces. )
HyperTerminal can be launched from the command prompt or by navigating menus.
Under Windows 2000\XP, for example, the software link can be found at the end of the following path of menus:
Start -> Programs -> Accessories -> Communications -> HyperTerminal -> HyperTerminal
windows_menu_hyperterminal.jpg
Menu hierarchy leading from the Start menu to HyperTerminal
When you start HyperTerminal, several dialog boxes appear:
hyperterminal_dialog_set.jpg
HyperTerminal dialogs:
1. Connection Description: Enter arbitrary name;
2. Connect To: Select port with modem (e.g., COM1);
3. COM1 Properties: Bit rate for the communication between the PC and the modem, etc.
I specified a low bit rate (2400 bits per second) between the PC and the modem simply because this is likely to work for every modem that is not officially an antique.
It is common for modern modems to communicate with the PC at rates around 115200 bits per second, even when the data rate on the telephone wire is as low as 9600 bits per second.
The following image shows a simple modem session using HyperTerminal:
hyperterminal_session01.jpg
Using HyperTerminal to attempt to use various modem commands
This notes above show an easy way to test a modem with the Windows operating system.
There are numerous other "serial communications" software programs for Windows and Linux.
For Linux (or UNIX variants) you might be able to do something similar to "echo atm2 > /dev/modem" on a command line, or fp = fopen( "/dev/modem", "w" ); followed by statements such as fprintf( fp, "atm2" ); in a simple C program.

8.6 Source code to control a modem

The C/C++ computer code shown below demonstrates transmitting text commands to a modem.
Although the computer code shown below is for the Windows operating system, the ideas are easily generalized for other operating systems.
#include < windows.h >

HANDLE  hCom = ((HANDLE)(0));

int  main()
{
DCB                dcb;
unsigned long int  n = 0;
char *             str = "COM1";

hCom = CreateFile( str, (GENERIC_READ | GENERIC_WRITE),
                   0, NULL, OPEN_EXISTING, 0, NULL );

GetCommState ( hCom, (&(dcb)) );

dcb.BaudRate = CBR_9600;
dcb.ByteSize = 8;
dcb.Parity   = NOPARITY;
dcb.StopBits = ONESTOPBIT;

SetCommState ( hCom, (&(dcb)) );

WriteFile( hCom, "ATM2\r", strlen("ATM2\r"), (&(n)), 0 );
FlushFileBuffers( hCom );
Sleep(1000);

WriteFile( hCom, "ATH1\r", strlen("ATH1\r"), (&(n)), 0 );
FlushFileBuffers( hCom );
Sleep(1000);

WriteFile( hCom, "ATDT5551212;\r", strlen("ATDT5551212;\r"), (&(n)), 0 );
FlushFileBuffers( hCom );
Sleep(3000);

WriteFile( hCom, "ATH0\r", strlen("ATH0\r"), (&(n)), 0 );
FlushFileBuffers( hCom );
Sleep(1000);

WriteFile( hCom, "ATM0\r", strlen("ATM0\r"), (&(n)), 0 );
FlushFileBuffers( hCom );
Sleep(1000);

CloseHandle( hCom );

return(0);
}
Copy of the demonstration code shown above: modem_test.cpp
The software above get access to a serial communication port (i.e., "COM1"), and we assume a modem is connected to this port.
The software sends text commands to the modem to do the following things:
1. Turn on the internal speaker ( "ATM2\r" );
2. Take the telephone wire "off hook" ( "ATH1\r" );
3. Dial a telephone number ( "ATDT5551212;\r" );
4. Put the telephone wire back "on hook" ( "ATH0\r" );
5. Turn off the internal speaker ( "ATM0\r" ).
The example computer code above shows some of the relevant Windows API functions.
However, the example computer code is very inflexible and does not check for any errors.
The Sleep() function invocations ensure that the modem has time to complete commands before advancing to the next command.
Ideally, we would check for text responses from the modem (e.g., "OK" or "ERROR").

8.7 Modem control C++ class (Windows operating system)

The following ZIP archive file contains a C++ class suitable for controlling a modem via the Windows operating system.
It is essentially a more elaborate version of the demonstration code presented above.
Also, the C++ class wraps the modem functionality in such a way that porting to other platforms (e.g., Linux) is made easier.
modem_control_v10.zip

4863 bytes
MD5: 47fe45adb6813f741243f861add7be29
A Microsoft Visual C++ 6.0 project file is included with the source code, so one can build and execute the code immediately as a test.
But all you need are the two relevant source files ( modem_control.cpp, modem_control.h ) to use the code in your own software.

9. Using the interface

9.1 Using the interface with a computer

phone_speech_system_custom_circuit.jpg
Configuration used in my experiments
Attach a splitter to the telephone wire, with one branch going to a modem, and the other branch going to the telephone interface circuit.
Connect the two audio wires from the circuit to the "microphone input" and "speaker output" of the sound card or audio sockets on the personal computer or other audio device.
Using the modem code described elsewhere in this article you can use the modem to "pick up the telephone" and "dial telephone numbers".
Then the computer can record and playback audio in any desired way.
The modem code can then be used to "hang up the telephone" to terminate the call.
You are responsible for notifying callers if you intend to record any portion of the call.
( ...unless you're the government! Otherwise, do as they say, and not as they do! )

9.2 Using the interface with audio equipment

Attach a splitter to the telephone wire, with one branch going to an ordinary telephone, and the other branch going to the telephone interface circuit.
Connect either audio signal from the circuit to a microphone input to an amplifier or recording device.
Connect the output of any device that produces low-amplitude audio (e.g., +/-1.0 Volts) to either audio socket on the circuit.
Do not connect the audio output of a stereo amplifier to the circuit, because the voltages are very likely to be very excessive for telephone audio.
Stereo amplifiers usually have special outputs (e.g., RCA connectors) for sending output audio to other kinds of audio equipment that accept audio input (e.g., VCR, tape recorder, television, etc); these low-voltage outputs are suitable for use with the circuit described in this article.
Thus, one can accept or place calls using the telephone, and record and play audio during the use of the telephone.
You are responsible for notifying callers if you intend to record any portion of the call.
( ...unless you're the government! Otherwise, do as they say, and not as they do! )

10. Telephone network concepts

10.1 Study references

The operation of the telephone system is beyond the scope of this article.
Consult the references at the end of this article for some information on the subject.
However, I discuss interesting highlights in this section.

10.2 Basic electrical aspects

10.2.1 Telephone or modem in the "on hook" state

There are two objectives that led to telephone design:
(1) A telephone should be electrically "invisible" to Direct Current (DC), just like an open circuit or a disconnection, when it is in the on-hook state;
(2) The Alternating Current (AC) spikes used to make telephones ring should be accepted by telephones in the on-hook state so they will ring.
Both of these goals are achieved by having the telephone designed such that a non-polarized capacitor (or two) is the telephone's only link to the telephone wire when in the on-hook state.
Thus, Direct Current (DC) cannot pass through, and the Alternating Current (AC) ringing signal can pass through to the bells or ringing circuit.
When I measured the DC resistance of a telephone in the on-hook state, it exceeded 40 Megaohms.
When I measured the DC resistance of a modem in the on-hook state, it also exceeded 40 Megaohms.
The DC voltage supplied by the telephone company to detect any resistance due to telephones being off-hook is sometimes reported as 48 Volts.
I measured +23.02 Volts (DC), where I called the "red wire" positive, and the "green wire" ground.
Note that this DC voltage drops dramatically when the telephone is taken off-hook; I measured +7.17 Volts (DC) when the telephone was in the off-hook status.
Ringing voltage is reported to be 90 Volts (16-60 Hz Alternating Current), which can startle or injure people under certain circumstances.

10.2.2 Telephone or modem in the "off hook" state

Telephones and Modems request use of a telephone wire by reducing their own DC electrical resistance.
This condition is detected by the telephone provider and the wire becomes active.
When I measured the DC resistance of a telephone in the off-hook state, it was approximately 6.83 Megaohms.
When I measured the DC resistance of a modem in the off-hook state, it was almost exactly 1.500 Megaohms.
Recall that both of these devices had resistances that exceeded 40 Megaohms when in the on-hook state.
Interestingly, this resistance is quite high, close to a human's electrical resistance when touching wires with dry hands.
For example, if I hold a wire in my left hand, and a wire in my right hand, with relatively dry hands, I can get a resistance as low as 0.5 Megaohms by squeezing tightly on the wires.
Squeezing very lightly gives me a higher DC resistance, approximately 1.5 Megaohms, which is apparently still low enough to tell the telephone company that I am a telephone.
(Never touch telephone wires!)
Thus, one can simulate taking a telephone or modem off-hook just by introducing a 1 Megaohm resistor across the telephone wire.
One can do this through a circuit with a relay controlled by a port on a computer (RS-232, parallel port, USB, etc), but a modem is a convenient, inexpensive, and versatile alternative to a custom relay circuit.
As mentioned above, the telephone company keeps a Direct Current (DC) potential difference (voltage) across the telephone wire to detect telephones going off-hook and returning to the on-hook state.
I measured this voltage as +23.02 Volts (DC) for on-hook, and +7.17 Volts (DC) for off-hook.

10.3 Audio signals

With the telephone in the off-hook state, the "dial tone" seems to have an Alternating Current (AC) Root-Mean-Square (RMS) voltage of 0.139 Volts AC.
The whole signal is biased by a significant DC voltage of approximately +5 Volts DC; I measured +7.17 Volts DC during an experiment.
The audio signals are very small deviations (just a few percent) around this DC voltage.
This means, for example, that the audio signals do not fluctuate around a zero voltage; the audio signals never make the current flow in the opposite direction on the telephone wire.
It turns out that my telephone interface circuit converts the 0.139 VAC signal to around 0.030 VAC (i.e., 30 mV AC) for use by audio equipment (e.g., microphone input on a sound card).

10.4 Audio bandwidth

The primary function of a telephone system is to enable voice communication between humans.
The following diagram shows the average spectral energy for a few seconds of speech audio.
basic_words_average_spectral_energy06.jpg
Average spectral energy (decibel scale) of several seconds of speech over the entire audible range (20 Hz to 20 kHz). The vertical scale is in decibels, so even a modest decrease on this graph indicates a dramatic decrease in sound energy.
The decibel scale of the chart above means that lower values on the chart are actually orders of magnitude less that higher values on the chart.
It is evident that a significant part of the total energy of speech sound is contained in the interval from 0 Hz to 4000 Hz.
Humans can reliably comprehend speech even when all audio energy outside the interval 300 Hz to 3000 Hz is eliminated.
However, the subjective effect of limiting audio energy to this range is that voices sound muffled and lack articulation.
The subtle difference between 'F' and 'S' is easily lost over a telephone.
The telephone system in the United States has a voice channel that only carries frequencies between 0 Hz to 4000 Hz.
However, the voice passband is restricted to the range 300 Hz to 3000 Hz, and there is rapidly increasing attenuation of voice energy outside of this band.
phone_bandwidth_diagram002.jpg
Voice bandwidth ( 300 Hz - 3000 Hz ) within the Voice Channel ( 0 Hz - 4000 Hz ) of the telephone system in the United States
The following image is a spectral plot of several seconds of a typical recorded telephone conversation.
cell_phone_audio_spectral_view.jpg
Spectral plot of several seconds of a typical recorded telephone conversation (male voice)
Although the frequency resolution is relatively low, the effect of the limited bandwidth of the telephone system is apparent.
For experimental purposes, the audio properties of a telephone system can be simulated with a graphic equalizer, or a bandpass filter in a sound editing software package, simply by filtering out everything below 350 Hz and everything above 3500 Hz.

10.5 Important audio frequencies

The "touch tones" used to "dial numbers" and interact with automated systems are known as Dual-Tone Multi-Frequency (DTMF) signals.
These tones can be generated simply by adding two sine waves together with the proper frequencies, as shown in the following matrix of frequencies.
Note that the minimum hold time when sending a DTMF sound is 50 milliseconds, and the minimum release time (silent gap between DTMF sounds) is 50 milliseconds.
Using delays of 200 milliseconds would probably be reliable.
dtmf_frequency_table.jpg
The "dial tone", "busy signal", and "ring-back" sounds also have defined frequency combinations in the United States:
phone_state_frequencies.jpg

11. Alternative telephone interface methods

I invested $30 and four hours to build the circuit to allow a personal computer to send and receive audio signals over a telephone wire.
This requires a cetain kind of expertise and equipment.
Also, unless you are willing to go in to the business of manufacturing this circuit, you cannot create a product (cheap voice-mail or answering machine) that requires this interface.
The easiest, inexpensive alternative to the hardware method I described in this article is to use a software method to access the voice capabilities of a "voice modem".
However, I must say that compared to using a custom circuit, using a voice modem in conjunction with special software is likely to be very platform-specific and generally very painful to program, configure, and use.
The benefit (assuming you have a voice modem) is that this would be a pure software solution.
If you use a voice modem and special software, your system could be as simple as the following diagram.
phone_speech_system_voice_modem.jpg
System using an internal "voice modem" and software
Depending on your needs, the voice data aspect of the voice modem can be half- duplex (i.e., software can "talk" or "listen", but not both simultaneously), or full-duplex.
Half-duplex may add some complexity to the controlling software because you need to decide when to transmit and receive audio.
The voice modem digitizes telephone wire audio and transmits the data over USB or RS-232 if external, or over the PCI bus, if internal.

12. Microsoft Telephony API (TAPI)

Microsoft operating systems have TAPI 2.0 and TAPI 3.0 DLLs.
TAPI 3.0 might have numerous software problems, and most people who have used Microsoft TAPI have simply used TAPI 2.0 (which has almost all desired functionality) instead of TAPI 3.0.
Use the "wave/in" and "wave/out" devices to get access to a voice modem's audio streams.
See the TAPI book in the references section of this article. The book is old, but it describes TAPI 2.0 in detail.

13. Java Telephony API

I do not know anything about the Java Telephony API.
However, I suppose it has the benefit of being independent of the operating systems, and probably has much simpler abstractions than the Microsoft TAPI!

14. Various commercial products

Commercial, rack-mounted hardware interfaces to multiple external telephone wires are capable of exchanging voice data with computers.
"Voice Over IP" (VoIP) products, such as "Internet telephones", are now everywhere (e.g., "Skype").
Obviously computer software can easily get access to the audio for such telephone connections.

15. References

Best, most comprehensive guide to telephone circuits I've encountered on the Internet:
http://www.hut.fi/Misc/Electronics/circuits/teleinterface.html
Another interesting reference:
http://www.repairfaq.org/ELE/F_ASCII_Schem_Tel.html
Hilarious (and insane) guide to pay-telephones around the United States and Canada:
http://www.payphone-directory.org
( Look at the "top contributors" of pay-telephone numbers, the telephone audio samples, and the telephone pictures. )

16. Books

16.1 Understanding Telephone Electronics (4th ed)

book_cover_telephone_electronics02.jpg
Understanding Telephone Electronics (4th ed);
Newnes; 2001;
Stephen J. Bigelow, Joseph J. Carr, Steve Winder;
$25.45 US (2001)
This book describes many aspects of telephone circuits and the operation of the telephone network in the US.
There are many details about circuits and protocols; everything from a telephone to the telephone network itself.
Undoubtedly the technology is very different now, but this book is probably somewhat more practical than a history book.

16.2 Windows Telephony Programming: A Developer's Guide to TAPI

book_cover_windows_tapi02.jpg
Windows Telephony Programming: A Developer's Guide to TAPI;
Addison-Wesley; 1998;
Chris Sells;
$33.95 US (1998)
The Microsoft Telephony API (TAPI) is unnecessarily messy and confusing, and is now extremely obsolete. The book mentioned above might be the only book ever published about the Microsoft Telephony API (TAPI).
colinfahey.com
contact information