[CM] [Snd] Searching conditionally for starts and ends of phrases

Ville Koskinen j.v.o.koskinen@gmail.com
Wed, 7 Mar 2007 16:19:33 +0200


Hello,

I'm a starting user trying to customize Snd to edit spoken word audio.
I'd like to use Snd to find starts and ends of utterances. I can
calculate rms values at cursor, but I can't figure out how to
integrate this to the search.

My code is listed below. I suppose I've misunderstood something about
make-moving-average, but I don't know what (I also haven't found out
how to debug my code, so that's a problem too.

Any help appreciated!

Regards,
-Ville Koskinen

(define (rms position)
  (let*  (  (data
            (channel->vct (max (- position 1024) 0) 1024)
          )
           (len
            (vct-length data)
          )
        )
    (sqrt (/ (dot-product data data) len))
  )
)

(define (phrase-lookup)
  (let* (  (search-for-sound
            (if (< (rms (cursor)) .05) 1 0 )
          )
           (bufferlen
            1024
          )
          (buffer
            (make-moving-average bufferlen)
          )
          (lowthreshold
            .00005
          )
          (highthreshold
            .001
          )
        )
    (lambda (y)
      (let   ((sum-of-squares (moving-average buffer (* y y)))
            )
            (if  (= search-for-sound 1)
                (> sum-of-squares highthreshold)
                (< sum-of-squares lowthreshold)
            )
      )
    )
  )
)