PBX in a Flash with CBeyond

Last week I deployed a PBX in a Flash system using SIPConnect from CBeyond. It was so successful that I will start using PIAF in lieu of Trixbox from now on for all future deployments of this type and will replace my home PBX to take advantage of Skype and Google Voice integration.

In this case I used the Aastra 53i (English edition) VoIP phones which when connected to the network, retrieved an IP from the DHCP server, contacted the PBX using mDNSResponse, checked and downloaded the most recent firmware available on the PBX, and downloaded the default configuration which prompts for a user to login. After login in the phone created a config file on the PBX for future restarts.

These Aastra phones come in 2 editions (The English/American edition and the European edition). The power supply for the European edition has different connectors and the display had symbols instead of words. Apart from that they appeared to be identical but getting the European edition to automatically connect to the PBX and configure itself was very painful, having to reset the phone to factory defaults and erase the local configuration multiple times and finally having to define on the phone the TFTP server (PBX) IP address for it to download the configuration.

Two thumbs up for the PBX in a Flash (PIAF) developers who have done a superb job with this distribution holding up the ideals of the original Asterisk@home open source project.

pbxinaflash

Their documentation was almost flawless although it was difficult trying to find the most recent version of instructions as they are all layed out in bits and pieces across a blog. In pursuit of a perfect install I narrowed down the install to running the iso install, going through the online download and compilation of asterisk and running the update/fix scripts. Now before upgrading/installing any module or OS updates, I downloaded and installed the files necessary to deploy the Aastra phones which is also done by a script and then I proceeded to install/update the software via the FreePBX module admin and finally the OS updates.

Below is the trunk configuration for connecting via SIPConnect to CBeyond from PBX in a Flash:

Outbound caller ID: 5551231234
Never overrride caller ID: checked
Maximum Channels: 6

Outbound Settings

trunk name=cbeyond

allow=ulaw&alaw&gsm&ilbc&g726&adpcm
context=from-trunk
disallow=all
dtmfmode=auto
fromdomain=sipconnect.dal0.cbeyond.net
host=sipconnect.dal0.cbeyond.net
insecure=very
outboundproxy=sip-proxy.dal0.cbeyond.net
qualify=250
secret=[secret-password]
type=peer
username=5551231234

Regitration String: 5551231234:secret-password@cbeyond/5551231234

Note: Notice there is no inbound settings required. DID incoming configuration will determine were each channel from the trunk will ring.

[ad]

Reblog this post [with Zemanta]

VoIP Phone Systems for Small Businesses

The more I research on the potential and possibilities of VoIP phone systems, the more companies I see trying to get a piece of the market.

Reminds me of a blog entry I read recently “Everything I Know About Business I Learned From Poker” and more specifically the quote: “If there are too many competitors (some irrational or inexperienced), even if you’re the best it’s a lot harder to win.” which definitely rings true here.

Below is a partial list of VoIP phone systems geared towards small businesses, meaning deployments of less than 50 phones. Although several of these systems can easily scale into the hundreds of phones.

  1. PhoneBochs from Rochbochs, Inc. (Duluth, MN based Rochbochs builds appliances based on Linux ranging from firewalls, asterisk telephony, Zimbra Email Collaboration and Fax over IP.)
  2. GXE502X from Grandstream. (Brookline, MA based Grandstream builds the GXE502x appliance, a powerful all-in-one voice + video + fax + data communication solution for the small to medium sized business)
  3. Jazinga PBX from Jazinga. (Toronto based Jazinga integrates data networking, traditional telephone service and low-cost Voice-over-IP (VoIP) service into one simple solution for small business and homes)
  4. Response Point from Microsoft. (Redmond, WA based Microsoft could not miss the action and introduced their next generation phone system for small businesses.)
  5. Trixbox from Fonality. (Los Angeles, CA based Fonality who acquired Trixbox which itself was re-branded from the open source project Asterisk @Home brings both software and appliance offerings to the table going beyond the small business market.)
  6. Switchvox IP PBX from Digium. (Huntsville, AL based Digium and the cradle of Asterisk brings forth their flagship product Switchvox which is probably one of the most popular offerings out there today.)
  7. TalkSwitch from Centrepoint Technologies. (Canada based Centrepoint, now TalkSwitch provides telecommunications solutions ideal for small and multi-location businesses with up to 32 telephone users per office.)
  8. PIKA WARP by PIKA Technologies. (Ontario, Canada based PIKA builds appliances focused on Asterisk and Linux solutions for small businesses.)
  9. BYOB by yourself. (Locally based, you can “Build Your Own Box” using Sangoma or Digium hardware for POTS landlines and build your own VoIP phone system using any Asterisk distribution, including Trixbox®, Elastix, AsteriskNOW, Elastix, CentPBX, and PBX-in-a-Flash, or FreeSWITCH, or YATE.

Amongst the other options available are the hosted solution where you pay a fixed cost per device, and then there’s the Colo solution where you would have one of the options above hosted by someone else.

There are many variables that need to be taken into account and every business is different.

Small businesses are likely to have some type of broadband connectivity to the Internet, whether cable or DSL and not the more reliable T1 circuit. Although I have not had any problems with my broadband connection for over 3 years, I have seen businesses add redundant cable and/or DSL because they have to stay up when their service gets interrupted occasionally during a storm.

The amount of simultanous calls at any one time and the codec used will also play a role in deciding if the hosted solution is viable, since most broadband providers do not offer symmetrical upload and download speeds but rather assimetrical where the upload is usually much lower than the download speeds.

My rule of thumb for a business with more than 10 phones and 3 lines with heavy phone usage is to stay with the premises PBX and only use VoIP trunks as secondary circuits for savings.

[ad]

Monitoring VoIP Trunks

Using VoIP lines to save on long distance and/or international calls is smart but real savings come in when you are able to dump your landline and go all the way with VoIP.

Over the years the technology has matured to the point where its possible to provide reliable phone service over the Internet. Vonage being a pioneer in this market and recently major telcos offering this service to their existing client base has begun to erode the excepticism on VoIP.

When migrating for landline to VoIP its very important for the service to just work. People expect the phone to have a dial tone when its picked up just as they expect the lights to come on when the switch is flipped. It has become a utility.

Even though VoIP has come a long way, its important to keep an eye on it. Because voice now travels the same path that data those, there is a wide variety of tools available to measure and monitor performance and availability.

The script below allows you to e-mail you the status of a SIP or IAX trunk on an asterisk based VoIP phone system. The script scheduled every 5 minutes would check the status of the registration status for the specific trunk.

We being by creating two files in the /etc/asterisk directory.

  • trunkalerts_iax.txt
  • trunkalerts_sip.txt

Each file contains the registration domain and port as shown when querying sip and iax registrations.

Example of trunkalerts_sip.txt

sip.broadvoice.com:5060

Script: (download here)

#!/usr/bin/perl

################################################## #############################
##################### ###########################
####
#### Trunk Alerts script written by Jim Hribnak Oct 7th 2007
#### if there is any questions please feel free to drop me an email at jimh at d
omain nucleus.com
#### Called using Cron job

################################################## #############################
##################### ###########################
####
#### Create the following 2 files in /etc/asterisk
####
#### in the files below add the hosts entry from asterisk -rx “sip show registry
” and
#### from asterisk -rx “iax2 show registry”.
####

open(IAXTRUNKS,”/etc/asterisk/trunkalerts_iax.txt”);
open(SIPTRUNKS,”/etc/asterisk/trunkalerts_sip.txt”);

################################################## #############################
##################### ###########################
####
#### SIP Related Code
####

#print “================================================= ===========n”;
#print “SIP Trunk information”;
#print “================================================= ===========n”;

while (<SIPTRUNKS>) {
chomp;
$siptrunks = `/usr/sbin/asterisk -rx “sip show registry” |grep “$_” | awk ‘{pr
int $4}’`;

#print “siptrunks = $siptrunks”;
if ($siptrunks =~ “Registered”) {
#print “$_ is upn” ;

} else {
#print “We have a problem”;
print “$_ trunk is not registering”;
mailalert();

}
} #end of while loop (read SIP file)

################################################## #############################
##################### ###########################
####
#### IAX Related Code
####

#print “nn============================================= ===============n”;
#print “IAX2 Trunk information”;
#print “================================================= ===========n”;

while (<IAXTRUNKS>) {
chomp;
$iaxtrunks = `/usr/sbin/asterisk -rx “iax2 show registry” |/bin/grep “$_” | aw
k ‘{print $5}’`;

#print “iaxtrunks = $iaxtrunks”;

if ($iaxtrunks =~ “Registered”) {
#print “$_ is upn” ;

} else {
mailalert();
print “We have a problem”;
print “$_ trunk is not registering”;
my $subject = “Subject: TRUNK $iaxtrunks is DOWN!!!!n”;
my $content = “TRUNK $iaxtrunks is DOWN!!!!n”;

}
} #end of while loop (read SIP file)

################################################## ########################
####
#### Email Subroutines
#### Change anywhere below where there is an email address an email addres
#### must have @ as perl needs to escape the @ symbol
####
################################################## ########################

sub mailalert {

my $sendmail = “/usr/sbin/sendmail -t”;
my $from= “FROM: <pbx@domain.com>n”; #replace xxx with your FROM email ID
my $reply_to = “Reply-to: <support@domain.com”;
my $subject = “Subject: $_ is DOWN!!!!n”;
my $content = “TRUNK $_ is DOWN!!!!n”;
my $send_to = “To:<support@domain.com>n”; #replace xxx with your TO email ID
open(SENDMAIL, “|$sendmail”) or die “Cannot open $sendmail: $!”;
print SENDMAIL $from;
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $send_to;
print SENDMAIL $content;
close(SENDMAIL);

#log
my $logfile = “/var/log/asterisk/trunkfailure.log”;
my $date = localtime();
my $logmsg = “$date TRUNK $_ is down”;
open LOGFILE, “>>$logfile” or die “cannot open logfile $logfile for append: $!”;
print LOGFILE $logmsg, “n”;
close LOGFILE;

print “An email has been sent!nn”;
}

[ad]

Asterisk Success Story

Just had to pass on what transpired today. I started a Tech Support call to Microsoft Partner Support at 9:05 this morning. The call was initially answered in Redmond by the Partner Group. It was then transferred (via IP) to India for First Level Support – this lasted for two hours, when it was kicked up to another level in tech support, and transferred (Again, via IP) to Montreal, CA. After another half hour, I had to attend a meeting, so the call was transferred (in house) to one of my Techs. He stayed on the line for another 1.5 hours, and then transferred the call back to me.

So at this point, I have had a live call that has been bounced over two continents, and in house over three extensions – this is at the 4-Hour point in the call.

The tech from M$FT then says that he needs a disk placed in the server – I place him on hold and call my contact, who is not there, so I transfer the call to my cel phone, and jump in the car and drive 15 minutes to the customer site. Stick the disk in, and resume troubleshooting on site and on the Cel, which has the call bridged through our Trixbox and out to my cel phone.

Two hours and 48 minutes later, and the M$FT guy is still not done, and my cell phone is going dead. Remote over to my desk at the office, call one of the people at my office and tell them I am giving them the call back, and to transfer it to a desk phone back where I am. I then bring up Flash Operator Panel, and put the call on his desk.

He then does a screened transfer to me, hits the receptionist at the school I am working at, asks for the server room, and when the phone rings and I answer, releases the call back to me!!!

Now, I am back talking to the M$FT guy, with no interruption WHATSOEVER and the call goes on for another 2 hours and 20 minutes!!!! He finally finishes what he was doing, and I sat back and looked at the statistics for the call:

9 Hours, 10 Minutes and 56 Seconds (I looked in the Log)
Three Locations and Two Continents (On the M$FT side)
Three internal Transfers, Two Offsite Transfers, and one Flash Operator Panel Call retrieval from an offsite location!!!!!!

And at no point did the call quality suffer – and all of this on a standard production Trixbox system!

Name me a system you could have done this on this easily!!!!

[ad]

Source: Trixbox Forums (GSnover)

Trixbox 2.6 and Sangoma Hardware

Trixbox (formerly Asterisk At Home – A@H) has definitely come a long since its beginnings in November 2004 and since I started playing around with Asterisk 2 months earlier. The convenience of being able to download an ISO and have a functional PBX in less than an hour was and is amazing.

An excellent resource is Ward Mundy’s blog Nerd Vittles, which I have also followed since early 2005 and has worked on some very cool and interesting projects augmenting Asterisk functionality. Most recently in November 2007, they released PBX In A Flash (PIAF) and have also announced a under $500 appliance with PIAF running on it.

What is Asterisk?

Asterisk is a software implementation of a telephone private branch exchange (PBX) originally created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services including the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, “*”.

What is Trixbox?

Trixbox is a turnkey business class PBX voice communication system based on the Open Source Asterisk project. It’s no longer necessary to pay thousands and thousands of dollars for a proprietary phone system. By simply downloading software and installing it on a low end system you can have a powerful, open, and robust pbx system. From small systems with only a couple analog phone lines and extensions to large installs with multiple T1/E1 connections and hundreds of extensions, you can easily use Trixbox to meet your telephony needs.

I believe Trixbox to be the most complete distribution of Asterisk out there, although many of its features might not be used in many cases. On the other side I have heard complaints on the lack of collaboration in adding new features and fixing bugs by the guys at Fonality, which makes it less open as it were.

Parts List:

  • Dell GX-150 with 512MB and 80Gb
  • Sangoma A200 card with 4 FXO ports

Todo List:

  • Upgrade the RAM to 512Mb and the hard drive to 80Gb
  • Install the Sangoma PCI A200 card
  • Insert CD into CD drive and boot from disk
  • Go through wizard and install Trixbox
  • Login to the computer, update Cent OS and download and install the drivers
    • yum update
    • yum upgrade
    • cd /opt
    • wget ftp://ftp.sangoma.com/linux/RPMS/2.6.1.13/wanpipe-util-3.2.7.1-0.i686.rpm
    • wget ftp://ftp.sangoma.com/linux/RPMS/2.6.1.13/wanpipe-modules-2.6.18-53.1.4.el5-3.2.7.1-0.i686.rpm
    • wanrouter hwprobe
    • wanrouter hwprobe verbose
    • setup-sangoma
      • When asked which codec will be used, select MULAW – North America
      • When configuration of the analog card completes, select 1 to continue
      • When configuration of Zaptel and Wanpipe completes, select 1 to save and restart deamons
      • When asked to start wanrouter at boot time, select 1 for yes
    • ztcfg -vv (to display the analog card installed and its modules.)
  • Install DynDNS client:
  • Create DynDNS account
  • Configuration ddclient: (Add to the end of the /etc/ddclient/ddclient.conf file)
    • use=web, web=checkip.dyndns.com/, web-skip=’IP Address’
    • server=members.dyndns.org,     
    • protocol=dyndns2,      
    • login=your-login,       
    • password=your-password       
    • pbx.dnsalias.com

Trixbox links to several good quick install guides here and a comprehensive list of documentation here.

[ad]

Hard SIP Phones – Cisco 7960 VoIP

Cisco 7960

Cisco 7960

Received my Cisco 7960 SIP phone and althought it was tough to get the firmware (7.4) [P0S3-07-4-00], it was pretty straight forward to get the phone running.

MORE…

Basically the configuration had to be erased, the phone unlocked and pointed to the asterisk server where the tftp daemon is and the firmware lies.

UPDATE:

Run the ‘setup-cisco’ command on the asterisk box to create the Default.cnf file.

The firmware here is essential. You MUST have this firmware in order for the Cisco phone to do SIP.

All the files needed *.bin, *.sbn, *.loads, and *.sb2 need to be located in the /tftpboot directory of the asterisk box and all files need to have 777 permissions.
The phone will need to be reset to factory defaults and set to pick up an IP address from the dhcp server. Once this is done the Alternate TFTP server will have to be keyed in pointing to the asterisk box. Doing a netstat -a on the asterisk box will show (udp 0 0 *:tftp) to make sure that the tftp daemon is listening.

Using the web GUI create a new phone configuration file. Use the MAC address of the phone which is located on the bottom of the phone. Edit the config file and update the Auth Name and password which you will use when setting up the extension later. Disconnect the phone and hopefully it will upload the firmware.

If you have problems then temporarily copy the files in /tftpboot/cisco_util/ /tftpboot/ and then once the phone has upgraded the firmware remove the the files.

At the end the /tftpboot directory should look like this:

drwxrwxrwx 2 root root 4096 Apr 29 2005 cisco_util
-rwxrwxrwx 1 root root 104 Jun 18 19:45 dialplan.xml
-rwxrwxrwx 1 root root 9570 Jun 18 19:45 merlin2.pcm
-rwxrwxrwx 1 root root 14 Jun 18 19:45 OS79XX.TXT
-rwxrwxrwx 1 root root 15 Jun 18 19:45 OS79XX.TXT.bk
-rwxrwxrwx 1 root root 129416 Jun 18 19:45 P003-07-3-00.bin
-rwxrwxrwx 1 root root 129820 Jun 18 19:45 P003-07-3-00.sbn
-rwxr-xr-x 1 root root 129472 Jun 18 19:45 P003-07-4-00.bin
-rwxr-xr-x 1 root root 129876 Jun 18 19:45 P003-07-4-00.sbn
-rwxrwxrwx 1 root root 459 Jun 18 19:45 P0S3-07-3-00.loads
-rwxrwxrwx 1 root root 592414 Jun 18 19:45 P0S3-07-3-00.sb2
-rwxrwxrwx 1 root root 582861 Jun 18 19:45 P0S3-07-3-00.zip
-rw-r–r– 1 root root 592222 Jun 18 19:45 P0S3-07-4-00.bin
-rwxr-xr-x 1 root root 461 Jun 18 19:45 P0S3-07-4-00.loads
-rwxr-xr-x 1 root root 592626 Jun 18 19:45 P0S3-07-4-00.sb2
-rwxrwxrwx 1 root root 26 Jun 18 19:45 RINGLIST.DAT
-rwxr-xr-x 1 root root 2335 Jun 18 19:45 SEP.cnf
-rwxr-xr-x 1 root root 2335 Jun 18 14:59 SEP.cnf.xml
-rwxrwxrwx 1 asterisk asterisk 2612 Jul 9 18:31 SIP.cnf
-rwxrwxrwx 1 root root 4074 Jul 9 18:29 SIPDefault.cnf
-rwxrwxrwx 1 root root 30 Jun 18 19:45 syncinfo.xml

UPDATE 2: (Thanks to Matthew Cochrane)

Upgrading factory SCCP load to current 7.4 SIP release:

1. Download 7.4 SIP firmware, and 7.1 (Cisco call manager) firmware (best I could ‘find’)
2. Unzip, and place both firmwares on your *@Home server in the tftpboot directory (copy 7.4 first, then 7.1) (winSCP did make it very easy). If you did not copy 7.4 first, change the OS79XX.TXT file to include “P003-07-1-00”
3. Run setup-cisco on *@Home server
4. Edit the image_version included in the SIPDefault.cnf to say “P003-07-1-00”
5. Ensure OS79XX.TXT has “P003-07-1-00” in it
6. Copy the contents of the cisco_utils directory to the foot tftpboot folder (cp /tftpboot/cisco_util/* /tftpboot)
7. Edit both new files (they start with xml and XML) so that the loadInformation7 and 8 have P003-07-1-00 in them.
8. Turn on phone
9. If you have DHCP configured correctly, then it should be pointed to your *@Home’s tftp server already, if not, manually setup the network configuration (see other guides online� key thing, press the settings button, go to network config, scroll down to “enable DHCP”, hit **#, and change to NO. Then type in your network settings, and have “alternate TFTP set to your asterisk server)
10. Your phone should now upgrade to 7.1, and reboot
11. If you phone says “Protocol Application Invalid”, your firmware flash failed, and your phone is now unrecoverable
12. Just kidding
13. Turn off your phone
14. Remove both xml files.
15. Edit the OS79XX.TXT and SIPDefault.cnf to now read “P0S3-07-4-00”
16. Turn your phone on.
17. It should now upgrade and reboot twice, finally saying that the phone is unprovisioned, but it should say SIP in the top right corner. Use the Cisco Config link on the maintenance page of *@Home and make a new phone configuration file.
18. Thank the internet, and whoever is hosting this guide for making your life oh-so-easy.

Connecting Two Asterisk @Home Servers via IAX2

I have found very scattered and little documentation on connecting two asterisk servers via IAX2, so I decided to put these words together. IAX2 is a protocol that plays nice with NAT and very powerful.

The most important thing to keep in mind is the client/server relationship when calling/forwarding from one server to another. So when you are calling from Server A to Server B, then Server A is the “Client” and Server B is the “Server” and of course if you are calling from Server B to Server A, then Server B would be the “Client” and Server A would be the “Server”.

MORE…

The next thing to know is that “Trunks” allow endpoints to establish a communication channel between each other, but Outbound & Inbound Routes also need to be established.

Home Server:

TRUNKS:

Add IAX2 Trunk

OUTGOING SETTINGS

Trunk name: SOHO
Peer Details:
auth=rsa
context=from-pstn
host=Office server IP address/dns address
inkeys=otherserver
secret=
type=friend
username=home

INCOMING SETTINGS

User Context: office
User Details:
context=from-pstn
host=dynamic
outkey=otherservervoip
secret=
type=friend
username=office

Registration String:
home:@

OUTBOUND ROUTING:

Dial Patterns:
7|.

Trunk Sequence:
Select trunk just built.

Office Server:

TRUNKS:

Add IAX2 Trunk

OUTGOING SETTINGS

Trunk name: SOHO
Peer Details:
auth=rsa
context=from-pstn
host=home server IP address/dns address
inkeys=otherserver
secret=
type=friend
username=office

INCOMING SETTINGS

User Context: home
User Details:
context=from-pstn
host=dynamic
outkey=otherservervoip
secret=
type=friend
username=home

Registration String:
office:@

OUTBOUND ROUTING:

Dial Patterns:
7|.

Trunk Sequence:
Select trunk just built.

Broadvoice on Asterisk

I signed up for a Broadvoice BYOD limited account which for about $6/month, I get 100 minutes of local calls and their great long distance rates…. at first it was a pain to set-up but this was probably because I was so tired… so I decided to give it one more try using instructions from http://www.geekgazette.com and voila…. it worked…. now I’m calling Venezuela at 3c/min…. can’t beat that…. http://geekgazette.com/index.php?option=com_content&task=view&id=20&Itemid=26

FreeWorldDialUp Access Numbers

The access numbers are as follows:

Atlanta                678-918-5026
Atlantic City                609-840-8027
Baltimore                410-372-4173
Chicago                708-437-9040
Connecticut                860-256-4170
Dallas                469-449-2560
Fort Worth                817-886-2285
Daytona Beach                386-267-2650
Houston                832-631-1597
Los Angeles                323-908-4167
Miami                786-206-4270
New York                347-427-9019
N. New Jersey                973-494-5586
S. New Jersey                609-873-8119
Philadelphia                610-879-1419
San Francisco                415-354-1083
Seattle                206-219-5789
Washington, DC                202-742-5739

Spain +34 902888232

Playing with audio files

Found a really cool website…. http://elvis.naturalvoices.com/demos/index.html
AT&T Text-to-speech engine with natural voices in US English, UK English, Spanish, German and French. Unfortunately its only good for 30 words so I needed a way to concatenate .wav files and then resample them at lower rates.

MORE…

**Concatenate wav files**

Copy and paste this script into a file called catwav in /usr/local/bin. Make it executable with the command chmod 755 /usr/local/bin/catwav.

#!/bin/sh
sox $1 -r 44100 -c 2 -s -w /tmp/$$-1.raw
sox $2 -r 44100 -c 2 -s -w /tmp/$$-2.raw
cat /tmp/$$-1.raw /tmp/$$-2.raw > /tmp/$$.raw
sox -r 44100 -c 2 -s -w /tmp/$$.raw $3
rm /tmp/$$*.raw

The correct syntax is:

catwav file1.wav file2.wav outputfile.wav

**Resample files using sox**

Converting your WAV files to good GSM files is easier than you might think if you have the program Sox installed. From the shell prompt, enter this command:

sox foo.wav -r 8000 foo.gsm resample -ql

and hit the key. In a few moments you will have a new GSM format file in the same directory as the original WAV file. In this example “foo.wav” is your main voice menu audio file in WAV format, and “foo.gsm” is the same file converted to GSM format. If you wanted to, you could use “main-voice-menu.gsm” as the name in place of “foo.gsm”: what matters here is the second file name you use in this command ends in “.gsm”.

If your WAV file was in stereo, add the -c1 option to convert to mono, or the output will sound very strange.

sox foo.wav -r 8000 -c1 foo.gsm resample -ql

You may get better results if you record your WAV file in 16 bit 8000 Hz mono and then run

sox foo.wav foo.gsm

If you have multiple WAV files in one directory and you want to convert them all, use this command:

for a in *.wav; do sox $a -r 8000 -c1 `echo $a|sed -e s/wav//`gsm resample -ql; done