Framing & windowing speech signal

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Post Reply
buttermuffin
Posts: 5
Joined: Sun Nov 15, 2020 11:56 am
Operating System: Windows 10

Framing & windowing speech signal

Post by buttermuffin » Mon Nov 16, 2020 12:54 pm

Hi.

Is it framing and windowing considered as a same step in speech signal preprocessing? And can I accomplish this tasks with Audacity? If can, how?

Thank you so much.

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Framing & windowing speech signal

Post by steve » Mon Nov 16, 2020 1:06 pm

"Framing" may mean splitting the data into small sequential and possibly overlapping chunks.
"Windowing" is used with overlapping chunks of data to provide a smooth transition from one chunk of data to the next. (more info about window functions here: https://en.wikipedia.org/wiki/Window_function)

This code from Audacity's Noise Removal effect gives an example of how windowing may be implemented in C++: https://github.com/audacity/audacity/bl ... emoval.cpp

This code gives an example of how windowing may be implemented in an Audacity Nyquist script:
(this code is from this "AGC" effect: viewtopic.php?p=194179#p194179)

Code: Select all

;nyquist plug-in
;version 4
;type process
;name "Automatic Gain Control..."
;action "Applying AGC..."
;author "Steve Daulton and Nicholas Kudriavtsev"
;helpfile "agc-help.html"
;copyright "Released under terms of the GNU General Public License version 2"

;control prefilter "Pre-filter audio source" choice "None (Music),Voice,Telephone" 1
;control mix "AGC strength" int "%" 100 0 100

;; To enable the "Gain reaction speed" control, remove one semicolon from the start of the next line:
;;control framesize "Gain reaction speed" real "seconds" 0.5 0.1 10

;control floor "Squelch threshold level" int "dB" -60 -60 -6
;control gate "Squelch attenuation" real "dB" 0 -30 0


(defun chan-max (sig)
"If stereo, return max of L/R"
  (if (arrayp sig)
      (s-max (snd-abs (aref sig 0))
             (snd-abs (aref sig 1)))
      sig))


(defun raised-cos (phase)
"Generate raised cosines for overlapping smoothing windows."
  (sum 1 (osc (hz-to-step (/ framesize)) 1 *sine-table* phase)))


(defun agc (sig)
  (let ((g0list '(0.0))     ; break-point lists for stepping gain adjustments
        (g1list '(0.0 ))
        (g2list '(0.0))
        ;; Each sample of "peaks" is the peak level of a 'framesize' window
        ;; where windows have 1/3 overlap
        (peaks (snd-avg (chan-max sig) frameln step OP-PEAK)))
    (do* ((peak (snd-fetch peaks) (snd-fetch peaks))
          (phase 0 (if (= phase 2) 0 (1+ phase)))
          (start 0 (+ start stepsize))
          (end framesize (+ start framesize)))
         ((not peak))
      (setf gain
        (if (> peak floor)  ; Squelch threshold
            (/ peak)        ; Normalize
            gate))          ; Squelch level
      (case phase
        (0 (setf g0list (append g0list (list start gain end gain))))
        (1 (setf g1list (append g1list (list start gain end gain))))
        (t (setf g2list (append g2list (list start gain end gain))))))
    (mult sig (/ 3.0)
      (sim
        (mult (abs-env (pwlv-list g0list)) (raised-cos 270))
        (mult (abs-env (pwlv-list g1list)) (raised-cos 150))
        (mult (abs-env (pwlv-list g2list)) (raised-cos 30))))))


;; The global variable "framesize" may be set by a control (if the control is enabled).
;; If the control is disabled (default), set it conditionally to 0.5 seconds.
(if (not (boundp 'framesize))
    (setf framesize 0.5))

(setf step (truncate (/ (* framesize *sound-srate*) 3.0)))  ; frames overlap by 1/3
(setf stepsize (/ step *sound-srate*))      ; step size in seconds
(setf frameln (* 3 step))                   ; frame size in samples
(setf framesize (/ frameln *sound-srate*))  ; actual frame size seconds

(setf wet (/ mix 100.0))
(setf dry (- 1 wet))

;; The effect GUI could be simplified by omitting the "Squelch attenuation" control
;; and calculating a value based on the "floor" threshold level.
;; In practice, the added flexibility of a separate contril is often useful.
(if (boundp 'gate)
    (setf gate (db-to-linear gate))
    (setf gate (/ (db-to-linear (* -1.0 (+ floor 30))) 2.0)))
(setf floor (db-to-linear floor))


;; Prefiltering:
(case prefilter
  (1  (setf *track*
        (if (>= *sound-srate* 16000)
            (lowpass2 (highpass4 *track* 150) 7000)
            (highpass4 *track* 150))))
  (2  (setf *track*
        (if (>= *sound-srate* 11025)
            (lowpass4 (highpass4 *track* 300) 5000)
            (highpass4 *track* 300)))))

;; wet/dry mix
(sum
  (mult wet (agc *track*))
  (mult dry *track*))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

buttermuffin
Posts: 5
Joined: Sun Nov 15, 2020 11:56 am
Operating System: Windows 10

Re: Framing & windowing speech signal

Post by buttermuffin » Mon Nov 16, 2020 1:34 pm

1. Are there any tutorial that I can follow on this topic?
2. Are there any other way apart from programming in C++?
3. What are the expected form of signal from this process?

Thank you.

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Framing & windowing speech signal

Post by steve » Mon Nov 16, 2020 1:54 pm

buttermuffin wrote:
Mon Nov 16, 2020 1:34 pm
1. Are there any tutorial that I can follow on this topic?
http://www.dspguide.com/ (recommended)
https://www.coursera.org/learn/audio-signal-processing
buttermuffin wrote:
Mon Nov 16, 2020 1:34 pm
2. Are there any other way apart from programming in C++?
See my second example ("Nyquist").
Windowing is essentially a DSP programming technique. If you are not a programmer, it's not really very relevant.

buttermuffin wrote:
Mon Nov 16, 2020 1:34 pm
3. What are the expected form of signal from this process?
See here: https://en.wikipedia.org/wiki/Window_function
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply