[xiph-cvs] cvs commit: speex/libspeex denoise.c speex_denoise.h testdenoise.c
Jean-Marc Valin
jm at xiph.org
Wed May 21 14:20:25 PDT 2003
jm 03/05/21 17:20:25
Modified: libspeex denoise.c speex_denoise.h testdenoise.c
Log:
improved the VAD with a simple Markov chain.
Revision Changes Path
1.11 +27 -0 speex/libspeex/denoise.c
Index: denoise.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/denoise.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- denoise.c 21 May 2003 19:53:08 -0000 1.10
+++ denoise.c 21 May 2003 21:20:25 -0000 1.11
@@ -152,6 +152,8 @@
st->loudness_weight[i] *= st->loudness_weight[i];
}
+ st->speech_prob = 0;
+ st->last_speech = 1000;
st->loudness = pow(6000,LOUDNESS_EXP);
st->loudness2 = 6000;
st->nb_loudness_adapt = 0;
@@ -381,6 +383,31 @@
}
/*fprintf (stderr, "%f %f ", mean_prior, mean_post);*/
+ {
+ float p0, p1;
+ float x = sqrt(mean_post);
+ p1 = .0005+.6*exp(-.5*(x-.4)*(x-.4)*11)+.1*exp(-1.2*x);
+ if (x<1.5)
+ p0=.1*exp(2*(x-1.5));
+ else
+ p0=.02+.1*exp(-.2*(x-1.5));
+
+ /*fprintf (stderr, "%f %f ", p0, p1);*/
+ p0 *= .99*st->speech_prob + .01*(1-st->speech_prob);
+ p1 *= .01*st->speech_prob + .99*(1-st->speech_prob);
+
+ st->speech_prob = p0/(p1+p0);
+ if (st->speech_prob>.5 || (st->last_speech < 15 && st->speech_prob>.2))
+ {
+ is_speech = 1;
+ st->last_speech = 0;
+ } else {
+ st->last_speech++;
+ if (st->last_speech<15)
+ is_speech = 1;
+ }
+ /*fprintf (stderr, "%f ", st->speech_prob);*/
+ }
if (mean_prior>1 && mean_post > 1)
{
is_speech=1;
<p><p>1.5 +2 -0 speex/libspeex/speex_denoise.h
Index: speex_denoise.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex_denoise.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- speex_denoise.h 21 May 2003 19:53:08 -0000 1.4
+++ speex_denoise.h 21 May 2003 21:20:25 -0000 1.5
@@ -60,6 +60,8 @@
float *inbuf; /**< Input buffer (overlapped analysis) */
float *outbuf; /**< Output buffer (for overlap and add) */
+ float speech_prob;
+ int last_speech;
float loudness; /**< loudness estimate */
float loudness2; /**< loudness estimate */
int nb_adapt; /**< Number of frames used for adaptation so far */
<p><p>1.5 +1 -1 speex/libspeex/testdenoise.c
Index: testdenoise.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testdenoise.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- testdenoise.c 21 May 2003 19:53:08 -0000 1.4
+++ testdenoise.c 21 May 2003 21:20:25 -0000 1.5
@@ -24,7 +24,7 @@
vad = speex_denoise(st, x);
for (i=0;i<NN;i++)
out[i]=x[i];
- /*fprintf (stderr, "%d\n", vad);*/
+ fprintf (stderr, "%d\n", vad);
fwrite(out, sizeof(short), NN, stdout);
}
speex_denoise_state_destroy(st);
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list