<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-2" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Waldek wrote:
<blockquote cite="mid41D95BCD.8080106@wp.pl" type="cite">Hi,
  <br>
I am looking how to setup speex codec in codecs.conf for 8 Kbps and 6
Kbps.
  <br>
In config file are many parameters for setting.
  <br>
I don't know what is need to change for narrowbad like 8 Kbps and 6
kbps.
  <br>
Any suggestion?
  <br>
  <br>
[speex]
  <br>
;0-10
  <br>
quality =&gt; 4
  <br>
;0-10
  <br>
complexity =&gt; 4
  <br>
; true / false
  <br>
enhancement =&gt; true
  <br>
; true / false
  <br>
vad =&gt; false
  <br>
; true / false
  <br>
vbr =&gt; false
  <br>
; 0 = off, otherwise, target bitrate in bps
  <br>
abr =&gt; 0
  <br>
;0-10
  <br>
vbr_quality =&gt; 5
  <br>
; true / false
  <br>
dtx =&gt; false
  <br>
  <br>
</blockquote>
<br>
For CBR, there is a 1:1 correlation between "quality" and bitrate. The
speex documentation has a table which describes this:<br>
here:<br>
<a class="moz-txt-link-freetext" href="http://speex.org/manual2/node9.html">http://speex.org/manual2/node9.html</a><br>
<br>
<table>
  <caption><strong>Table 4:</strong>
Quality versus bit-rate</caption>
  <tbody>
    <tr>
      <td>
      <table border="1" cellpadding="3">
        <tbody>
          <tr>
            <td align="center">Mode</td>
            <td align="center">Bit-rate<a name="404"></a> (bps)</td>
            <td align="center">mflops<a name="405"></a></td>
            <td align="center">Quality/description</td>
          </tr>
          <tr>
            <td align="center">0</td>
            <td align="center">250</td>
            <td align="center">N/A</td>
            <td align="center">No transmission (DTX)</td>
          </tr>
          <tr>
            <td align="center">1</td>
            <td align="center">2,150</td>
            <td align="center">6</td>
            <td align="center">Vocoder (mostly for comfort noise)</td>
          </tr>
          <tr>
            <td align="center">2</td>
            <td align="center">5,950</td>
            <td align="center">9</td>
            <td align="center">Very noticeable artifacts/noise, good
intelligibility</td>
          </tr>
          <tr>
            <td align="center">3</td>
            <td align="center">8,000</td>
            <td align="center">10</td>
            <td align="center">Artifacts/noise sometimes noticeable</td>
          </tr>
          <tr>
            <td align="center">4</td>
            <td align="center">11,000</td>
            <td align="center">14</td>
            <td align="center">Artifacts usually noticeable only with
headphones</td>
          </tr>
          <tr>
            <td align="center">5</td>
            <td align="center">15,000</td>
            <td align="center">11</td>
            <td align="center">Need good headphones to tell the
difference</td>
          </tr>
          <tr>
            <td align="center">6</td>
            <td align="center">18,200</td>
            <td align="center">17.5</td>
            <td align="center">Hard to tell the difference even with
good headphones</td>
          </tr>
          <tr>
            <td align="center">7</td>
            <td align="center">24,600</td>
            <td align="center">14.5</td>
            <td align="center">Completely transparent for voice, good
quality music</td>
          </tr>
          <tr>
            <td align="center">8</td>
            <td align="center">3,950</td>
            <td align="center">10.5</td>
            <td align="center">Very noticeable artifacts/noise, good
intelligibility</td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
  </tbody>
</table>
<br>
Of course, this table isn't helpful unless you also know this:mapping
between "quality" setting, and modes:<br>
modes_noglobals.c:  int quality_map[11] = {1, 8, 2, 3, 3, 4, 4, 5, 5,
6, 7};<br>
<br>
so:<br>
quality 0 = mode 1 = 2,150kbps.<br>
quality 1 = mode 8 = 3.950kbps<br>
quality 2 = mode 2 = 5.950kbps <br>
quality 3 = mode 3 = 8.000kbps<br>
quality 4 = mode 3 = 8.000kbps<br>
quality 5 = mode 4 = 11.000kbps<br>
quality 6 = mode 4 = 11.000kbps<br>
quality 7 = mode 5 = 15.000kbps<br>
quality 8 = mode 5 = 15.000kbps<br>
quality 9 = mode 6 = 18.200kbps<br>
quality 10 = mode 7 = 24.600kbps<br>
<br>
Maybe that should go into the docs somewhere.  (it might have been
easier if the "bitrate" parameter was specified, so you could just
choose a bitrate, but that's not the way it was done.<br>
<br>
I just contributed the fix to CVS for ABR mode, however.  ABR mode will
use a variable bitrate in order to meet an "average" bitrate target. 
It's easy to specify, and works really well.<br>
<br>
To use this, just choose set the bitrate, in bps, you want in the abr
=&gt; parameter.  For example, use abr =&gt; 8000.  This will in
general, sound significantly better than the CBR mode at the same
bitrate, since it will use more bits for more complex parts of speech,
and less bitrates for less complex parts.  It does use more CPU, of
course, in this mode..  Which brings me to the next point:<br>
<br>
The "complexity" parameter basically tells the codec how much CPU to
use.  If it's using too much CPU, set the complexity down a bit.  2 or
3 are usually good choices, although 1 works fine if you're short of
CPU.  This only affects encoding, and doesn't affect the bitrate, but
basically tells the codec how hard to search for the "best" bits to
represent the speech.<br>
<br>
To directly answer your question, I'd suggest these settings for you:<br>
<br>
[speex]
<br>
;0-10
<br>
quality =&gt; 4
<br>
;0-10
<br>
complexity =&gt; 4
<br>
; true / false
<br>
enhancement =&gt; true
<br>
; true / false
<br>
vad =&gt; false
<br>
; true / false
<br>
vbr =&gt; false
<br>
; 0 = off, otherwise, target bitrate in bps
<br>
abr =&gt; 8000<br>
;0-10
<br>
vbr_quality =&gt; 5
<br>
; true / false
<br>
dtx =&gt; false
<br>
<br>
And if you are CPU bound, lower the complexity..<br>
<br>
-SteveK<br>
<br>
<br>
<br>
</body>
</html>