HOWTO - Install the Speex Codec.

rasker
Posts: 529
Member Since:
2006-06-02

The speex codec is a freeware compression codec. It can significantly reduce the ammount of bandwidth usage that an asterisk server needs. It also can be used in 'wideband' which means one can get similar audio performance to Skype or Teamspeak. It has good bandwidth performance comparable to some of the more modern codecs in use and there are no licence fees.

To use speex your phone must also support the codec. IAXphone and IDEfisk softphones both support Speex.

Steps to install Speex:

The Speex Codec can be installed in two versions. The stable version is time tested and will produce good bandwidth usage improvements. The development version is considered 'unstable' but has the advantage of being better optimised code (using less CPU), supports 'wideband' audio (better quality audio) and other audio improvements for the same bandwidth.

The stable version of speex can be installed through yum:

yum -y install speex

The development branch needs to be installed from source. The benfits of this might not be worth the effort as both ends of the conversation need to use the development branch to gain the best improvement in audio. However the CPU benefits will be felt on the asterisk server.

The development branch can be installed as follows:

Make sure some initial packages are installed:

yum install automake gcc-c++ autoconf libtool libogg-devel

Get the source:

cd /usr/src
wget http://downloads.us.xiph.org/releases/speex/speex-1.1.12.tar.gz
tar -zxvf speex-1.1.12.tar.gz
mv speex-1.1.12 speex

Compile:
cd speex
./configure
make
make install

We need to create the speex module for asterisk:

Get the asterisk source code for the version you have installed. Use this --> http://www.trixbox.org/modules/newbb/viewtopic.php?topic_id=1359&forum=7

cd /usr/src/asterisk
make

The compile process will see the speex codec installed and will build the asterisk speex module.

We don't want to disturb our existing install too much so we just copy the module to asterisk lib directory.

cp codecs/codec_speex.so /usr/lib/asterisk/modules

Speex has to be enabled for asterisk to use the codec. edit the iax.conf and the sip.conf files in /etc/asterisk and add the allow = speex line.

Various speex settings can be changed in the /etc/asterisk/codec.conf file. This is especially important if you have decided to use the development version. Things like a better version of Voice Activity Detection and a preprocessor can be switched on. For the stable version of Speex you can leave the settings as they are.

Hope this is fun for someone to try. Post back with your experiences.

Rehan



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Hi Rehan,
I want to use speex codec for remote iax extension, I am using Dante's diax softphone to connect to my Trixbox. I read your instructions on how to install speex codec in to Trixbox, I am not a linux guy so I am bit confuse what part of instructions are for stable speex version only, because you have put both stable version and development version instructions togather. I put togather some steps from your posts, would you please confirm that these are the steps I need to install stable speex codec. Thanks.

Steps to install Speex:

The stable version of speex can be installed through yum:

yum -y install speex

Get the asterisk source code for the version you have installed:

cd /usr/src
svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2 --revision 34876

(change the revision number according to the number you see after typing 'asterisk -r'. 34876 is the

number from trixbox 1.1. If your installation does not have an SVN revision then it is likely that you are

using a release version. Just download the source from www.asterisk.org by clicking the 'more...' and

then 'asterisk' download links on the top right and finding your version)

mv asterisk-1.2 asterisk (adjust as neccessary.)

This will put the sources in /usr/src/asterisk
cd /usr/src/asterisk
make

The compile process will see the speex codec installed and will build the asterisk speex module.
We don't want to disturb our existing install too much so we just copy the module to asterisk lib directory.

cp codecs/codec_speex.so /usr/lib/asterisk/modules

Speex has to be enabled for asterisk to use the codec. edit the iax.conf and the sip.conf files in

/etc/asterisk and add the allow = speex line.



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

It looks right for the stable version.

I learned later that the order of the codecs is important in the iax.conf and sip.conf. You will need to have the allow=speex as the first codec listing after the disallow=all line otherwise when asterisk calls the phone it will use the ulaw codec by default. (when the fone calls asterisk it will request the speex codec if you have it set that way).

The development version is pretty stable as well and will use the FPU and (I think) the MMX instructions on the asterisk processor if available. If you are making/receiving a lot of calls you should consider using it. The decoder at the phone end will support both versions.

Many Speex settings are set in the codecs.conf file. If you leave this as default then the development version will behave in a similar way to the stable version but use optimised CPU instructions.

What audio quality do you get? I got pretty good audio when I tested it.

Rehan



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Thanks for the reply,
I will give it a try tonight and let you know about the results. For the moment I use GSM or iLBC for the remote end, because my remote extension is on dialup connection the audio quality is not so great, that's the reason I want to try Speex codec. With the above codecs I can hear them well but they hear me with broken voice. I hope with Speex the things will get better.



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Rehan,
I did follow the steps I have mentioned in my post above but after all the process finished without any error there was no file in codecs dir name codec_speex.so , then I followed your post step by step and I got the codec installed into modules. I tried a call from iax soft phone to my sipura via trixbox but no audio, if I change the codec in iax soft phone to gsm or ilbc audio is ok, if I make a call from soft phone to soft phone with speex codec on both sides via trixbox call is ok. So I think trixbox is not doing the translation from speex to any other codec, may be the codec_speex.so file is no good or I may have to change parameters in codec.conf file. Any help on this one please.



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

Try the commands posted here and post your results up.

I have seen a similar issue on my tests. I believe that asterisk fails to choose another codec after the initial request to choose speex fails as we have allowed it globally in sip.conf.

To work around this you can do one of two things:

1) as you are using iax for your soft phone remove the allow=speex in the sip.conf. This should be fine if none of your sip phones support speex.

2) Specify the codecs in the extension itself. I think this is in extesions_custom.conf. Find the Sipura extension and make sure it says something like:

disallow = all
allow = ulaw
allow = alaw
+ any other codecs it supports.

If you can try both separately and post back the results as I am not sure how this will work exactly. Whichever one works I'll add to the HOWTO.

Thanks
Rehan

Rehan



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Hi Rehan,
I followed your first post and I got no errors during installation, when I enter command show translation codec_speex.so shows the translation time in front of that. I put allow=speex only in iax.conf not in sip.conf, when I try to call from iax soft phone that has only speex codec enabled to a sip extension, phone rings but no audio, and I also noticed that if I go to System Maint tab the asterisk is showing stopped instead of running and I have to restart asterisk again. Just to do a test I took a file codec_g729-gcc-pentium2.so from http://kvin.lv/pub/Linux/Asterisk/built-for-asterisk-1.2-untested...
and rename it to codec_g729.so and copy into modules dir and that works good. So I am suspecting that there is something wrong with compile process. Please verify the steps in your post just to confirm if we are not missing any thing there. Thanks.



TomChez
Posts: 1
Member Since:
2006-07-15
Re: HOWTO - Install the Speex Codec.

Hi,
The speex codec is not working very well for me. I followed these instructions but I cannot transcode or use it in a meetme conference.

Ext to ext is working (sorta) with the idefisk softphone. With the default settings I get some noise when talking. When I change the settings for better quality / higher complexity, I get a 2-3 second delay when talking across a LAN at either extension.

I checked out the development version and compiled it on an Intel SMP machine.

Can anyone verify that they have successfully installed and used the speex codex with good results? (development or stable)

Thanks

Tom



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Anybody help please...



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

Hi

I believe that asterisk is compatible with/needs the latest development version and that the version has to be at least 1.1.8. Sorry did not know this before

I have it working successfully to a certain extent. If a softphone is set to use speex then when it calls asterisk it sets up speex ok.

e.g.

softphone -->asterisk --> ISDN

Softphone is in speex mode.

However

ISDN -->asterisk --> speex it appears that the call is passed in ulaw.

Not really sure how to change the settings for this.

see here for more info:

http://www.voip-info.org/wiki/view/Speex

and here for explanations of the codecs.conf settings:

http://en.wikipedia.org/wiki/Speex

R



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

@Arsh

Do you have any zaptel interfaces? Or even ztdummy loaded at all?

Rehan



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Hi Rehan,
I am bit confused now, I think according to your how to's we are already using speex version 1.1.12. Would you please modify your how to's guide, so we can follow the new instructions to install speex codec. I do not have a zaptel interface, I have ztdummy loaded.



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

Hi Arsh,

Yeah 1.1.12 is ok (twelve is higher than eight, weird how the numbering works).

Can you run a 'show translation' command and post the results.

I just looked at your original post. Not sure how much success you'll have over dialup whatever the codec. See here (under show translation)

http://www.automated.it/asterisk/lah-3-6-05_4.html

It looks like g723 uses the least bandwidth but there are no numbers for speex. In my testing my dsl modem is showing about 40-42 kbps each way (reducing to 0 when there is no voice traffic). Of course this can be heavily tweaked to use less bandwidth at the loss of audio quality (I guess the settings in codecs.conf).

Does the ata have a log? You could check there. I'm pretty sure that the no audio issue is related to asterisk pushing speex to the ata and the ata not supporting it.

R



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

Hi Rehan,
I have installed the speex-1.1.12 and still have problems to make it run, when ever I try the speex codec I get this message,

Accepting AUTHENTICATED call from 192.168.0.103:
> requested format = speex,
> requested prefs = (),
> actual format = speex,
> host prefs = (ilbc|gsm|g729|speex),
> priority = mine
-- Executing Answer("IAX2/2003-4", "") in new stack
-- Executing Wait("IAX2/2003-4", "1") in new stack
-- Executing VoiceMailMain("IAX2/2003-4", "") in new stack
asterisk1*CLI>
Disconnected from Asterisk server
Executing last minute cleanups
[root@asterisk1 ~]#

Here is the result of show Translation command,
asterisk1*CLI> show translation
Translation times between formats (in milliseconds)
Source Format (Rows) Destination Format(Columns)

g723 gsm ulaw alaw g726 adpcm slin lpc10 g729 speex ilbc
g723 - - - - - - - - - - -
gsm - - 5 5 22 5 4 18 89 133 74
ulaw - 12 - 1 19 2 1 15 86 130 71
alaw - 12 1 - 19 2 1 15 86 130 71
g726 - 29 19 19 - 19 18 32 103 147 88
adpcm - 12 2 2 19 - 1 15 86 130 71
slin - 11 1 1 18 1 - 14 85 129 70
lpc10 - 23 13 13 30 13 12 - 97 141 82
g729 - 28 18 18 35 18 17 31 - 146 87
speex - 26 16 16 33 16 15 29 100 - 85
ilbc - 26 16 16 33 16 15 29 100 144 -
asterisk1*CLI>



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

Hi Arsh,,

Not sure again what the issue you are having is. The call log states that you are receiving a call and speex is being used. So sppex is installed and working!!

Now the bad news. The numbers you are getting for speex and g729 are probably too high to be useful. (you'll have to google 'asterisk show translation' for some example numbers and other peoples experience with these numbers). This is entirely processor dependant so you could use a machine with a faster processor (or better still some sse and mmx instructions at a faster processor speed). These numbers in combination with the (probably) higher latency of your dial up will at the least give you audio problems at most dropped calls.

Better options would be gsm or g726.

:(

Rehan



arsh
Posts: 19
Member Since:
2006-05-31
Re: HOWTO - Install the Speex Codec.

I just noticed that the format_speex.so file is not in the modules dir, I can see all codec types have the format_codec name.so files beside speex. May be that's the problem?. Also you have mentioned that the G723 may be a good choice for dialup connection, so I looking for an iax soft phone with g723 codec.



rasker
Posts: 529
Member Since:
2006-06-02
Re: HOWTO - Install the Speex Codec.

As far as I know there is no format_speex file needed. Anyway if there was a problem with speex the speex column would not get populated (there would be dashes).

Rehan



sgavitt
Posts: 7
Member Since:
2006-06-09
Re: HOWTO - Install the Speex Codec.

Rehan-

It appears I have had a similar problem, to where during the compile process, I did not get any errors until I tried to rename the codec_speex.so file.
the (cp codecs/codec_speex.so /usr/lib/asterisk/modules) section of your tutorial

The only file I have under /usr/src/asterisk that is related to speex is:
codec_speex.c

Am I doing something wrong?

asterisk1*CLI> show translation
Translation times between formats (in milliseconds)
Source Format (Rows) Destination Format(Columns)

g723 gsm ulaw alaw g726 adpcm slin lpc10 g729 speex ilbc
g723 - - - - - - - - - - -
gsm - - 2 2 6 2 1 5 - - 21
ulaw - 4 - 1 6 2 1 5 - - 21
alaw - 4 1 - 6 2 1 5 - - 21
g726 - 8 6 6 - 6 5 9 - - 25
adpcm - 4 2 2 6 - 1 5 - - 21
slin - 3 1 1 5 1 - 4 - - 20
lpc10 - 6 4 4 8 4 3 - - - 23
g729 - - - - - - - - - - -
speex - - - - - - - - - - -
ilbc - 7 5 5 9 5 4 8 - - -

Thanks in advance!



rizsher
Posts: 224
Member Since:
2006-07-18
Re: HOWTO - Install the Speex Codec.

Same here. Thee are the only files in the directory:

adpcm_slin_ex.h  codec_g726.o    codec_ulaw.c     Makefile
codec_adpcm.c    codec_g726.so   codec_ulaw.o     slin_adpcm_ex.h
codec_adpcm.o    codec_gsm.c     codec_ulaw.so    slin_g723_ex.h
codec_adpcm.so   codec_gsm.o     g723_slin_ex.h   slin_g726_ex.h
codec_alaw.c     codec_gsm.so    g726_slin_ex.h   slin_gsm_ex.h
codec_alaw.o     codec_ilbc.c    gsm              slin_ilbc_ex.h
codec_alaw.so    codec_ilbc.o    gsm_slin_ex.h    slin_lpc10_ex.h
codec_a_mu.c     codec_ilbc.so   ilbc             slin_speex_ex.h
codec_a_mu.o     codec_lpc10.c   ilbc_slin_ex.h   slin_ulaw_ex.h
codec_a_mu.so    codec_lpc10.o   log2comp.h       speex_slin_ex.h
codec_g723_1.c   codec_lpc10.so  lpc10            ulaw_slin_ex.h
codec_g726.c     codec_speex.c   lpc10_slin_ex.h 

There is no codec_speex.so file.



wooster
Posts: 1
Member Since:
2006-09-04
Re: HOWTO - Install the Speex Codec.

Thank you for the excellent how to Rehan, Worked like a charm on Xen-Centos system



JuanJo
Posts: 1
Member Since:
2006-10-09
Re: HOWTO - Install the Speex Codec.

I'm having the same problem, when I enable speex in sip.conf and any
voip client tries to use it I get:
# asterisk -r
voip*CLI>
Disconnected from Asterisk server
, and asterisk process disappears.

I've followed same procedure (adapted to trixbox-1.2):
# rpm -q kernel asterisk speex
kernel-2.6.9-42.0.2.EL
asterisk-1.2.12.1-2.42879
speex-1.1.9-1 ### compiled from src.rpm
# cd /usr/src
# svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2 --revision 42879
# cd asterisk-1.2
# make
# cp -p codecs/codec_speex.so /usr/lib/asterisk/modules/codec_speex.so
# vi /etc/asterisk/sip.conf ### allow=speex
# /etc/init.d/asterisk restart
# asterisk -r
voip*CLI> show translation
Translation times between formats (in milliseconds)
Source Format (Rows) Destination Format(Columns)

g723 gsm ulaw alaw g726 adpcm slin lpc10 g729 speex ilbc
g723 - 12 5 5 17 5 4 14 65 73 56
gsm 86 - 4 4 16 4 3 13 64 72 55
ulaw 84 9 - 1 14 2 1 11 62 70 53
alaw 84 9 1 - 14 2 1 11 62 70 53
g726 95 20 13 13 - 13 12 22 73 81 64
adpcm 84 9 2 2 14 - 1 11 62 70 53
slin 83 8 1 1 13 1 - 10 61 69 52
lpc10 91 16 9 9 21 9 8 - 69 77 60
g729 95 20 13 13 25 13 12 22 - 81 64
speex 94 19 12 12 24 12 11 21 72 - 63
ilbc 93 18 11 11 23 11 10 20 71 79 -

Any help will be much appreciated ... regards,
--
--JuanJo

--

--
--JuanJo



vjfromgt
Posts: 192
Member Since:
2006-11-11
Eats up bandwidth

I have a weird issue
when i use speex my bandwidth on my network gets eaten up
ping to yahoo typically give 20 ms, when using speex ,i get pings of 900 ms

g729 works fine



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.