Branch Log · Open in interactive viewer →

Section 3: Fundamental of Audio Processing

3.4 From human to computers


3.4.1 Signal collection

microphone(마이크)는 sound wave를 electrical signals로 변환하는 transducer(변환기)이다.

다음은 membrane microphone의 구조이다.

membrane


3.4.2 Phone connector

(생략)


3.5 Analog-to-digital

컴퓨터에 저장되는 audio signals은 digital이다. 따라서 컴퓨터의 Sound cards는 다음과 같은 기능을 갖는다.


3.5.1 Sampling

만약 signal이 periodic signal이라면, 주기당 적어도 두 배의 sampling rate가 필요하다.(crest, trough를 모두 sampling하기 위함)

다음은 20Hz sine wave를 여러 sampling rate에서 sampling한 예시다.

sampling


3.5.1.1 Sampling rate examples

몇 가지 대표적인 sampling rate를 살펴보자.


3.5.2 Quantization

quantization(양자화)란 실수인 amplitude를 integer로 변환하는 과정이다.

quantization은 주로 다음과 같은 종류로 나뉜다.


3.6 Audio coding

sampling과 quantization 단계가 끝나면, audio는 integer series로 표현된다. 이를 더 효과적으로 저장하고 전송하기 위해서는 bytes 단위로 표현할 필요가 있다.


3.6.1 Linear PCM

다음은 16 level로 나뉘어진 Linear PCM 예시이다.

linear PCM


3.6.2 Non-linear PCM

그러나 사람의 청각은 intensity에 linear하지 않다.(small amplitude에 더 민감하다.)

따라서 samller amplitude일수록 큰 precision을 갖는 non-linear PCM이 더 효과적이다.

두 가지 대표적인 non-linear PCM으로는 다음과 같은 기법이 있다.

먼저 $x \in [-1, 1]$ , $\mathrm{sgn}(x)$ : sign function으로 가정한다.

$$ F(x) = \mathrm{sgn}(x){{ln(1+\mu|x|)} \over {\ln(l+\mu)}} $$

$$ F(x) = \mathrm{sgn}(x) \begin{cases} {{A|x|} \over {1 + \ln A}}, & |x| < {1 \over A} \ {{1 + \ln(A|x|)} \over {1+ \ln A}}, & {{1} \over {A}} \le |x| \le 1 \end{cases} $$

μ-law, A-law 모두 다음과 같은 조건을 만족한다.

$$F(x) = x \quad when \, \, x \in {0, -1, 1}$$

만약 8-bit coding이라면 μ=255, A=87.6 값을 갖는다.

linear vs non-linear


3.6.3 Adaptive PCM

linear, non-linear PCM은 모든 sample에서 global strategy로 적용된다. 하지만 시간에 따라 signal이 갖는 amplitude는 바뀔 수 있다.

이러한 문제를 adaptive PCM은 local amplitude를 normalize한 뒤 quantization을 적용하여 해결한다.


3.6.4 Differential PCM

sampled series $x[n]$ 가 있다고 하자.

$$ e[n] = x[n] - x[n-1] $$

$e$ : prediction error

delta를 사용하는 이유는 $e[n]$ 이 갖는 dynamic range가 $x[n]$ 보다 훨씬 작기 때문에, 매우 작은 bit rate로도 효과적으로 표현할 수 있기 때문이다.


3.6.5 Linear Predictive Coding

Linear Predictive Coding(LPC)은 DPCM보다 더 generic한 표현이다. 둘의 차이를 비교하며 알아보자.


3.6.5.1 Derivation of LPC

Linear Predictive Coding is All-Pole Resonance Modeling

human voice production에서 signal이 만들어지는 과정을 복습해 보자.

LPC model

$$ x(n) = h(n) \ast e(n) $$

그러나 현재 알고 있는 정보는 오직 $x(n)$ ,즉 resulting siganl뿐이다. 이 정보를 바탕으로 $e(n)$ 과 $h(n)$ 를 추정해야 한다.

따라서 다음과 같이 수식을 유도할 수 있다.

$$ X(z) = H(z)E(z) = {{1} \over {1 - \sum_{k=1}^{p}a_k z^{-k}}}E(z) $$

$$ X(z) = \sum_{k=1}^{p}a_kz^{-k}X(z) + E(z) $$

$$ 𝒵 \Leftrightarrow x(n) = \sum_{k=1}^{p}a_k x(n-k) + e(n) $$


3.6.6 Other coding approaches

이외에도 다양한 audio coding 기법이 존재한다.

$e[n]$ 으로 single bit를 사용한다.


3.6.7 Frequency domain coding

~3.6.6절까지는 waveform signal을 기반으로 한 접근법이다.

Frequency domain coding은 speech보다는 music에서 더 사용되는 기법이다.

대표적인 Frequency domain coding으로 다음과 같은 기법이 있다.


3.6.8 Case study: Google Cloud Speech-To-Text

Google Cloud에서 제공하는 Speech-To-Text API를 사용하려면, audio coding 기법이 무엇인지 특정해야 한다. 다음은 API가 지원하는 audio encoding 기법 목록이다.

google cloud speech-to-text


3.7 Audio formats

audio formats는 signal encoding에서 어떻게 bit stream으로 표현할지를 정의한다. 이러한 format은 크게 세 종류로 나눌 수 있다.


3.7.1 WAV format

Microsoft WAVE format (.wav)

가장 흔하게 쓰이는 format 중 하나인 Waveform Audio File Format(WAV)는 Resource Interchange File Format(RIFF)의 application이다.

WAV format


3.7.1.1 WAV format example

실제 WAV format 예시를 살펴보자.

WAV format example


3.7.2 SPHERE format

SPeech HEader Resources(SPHERE)은 대중적인 format은 아니나 speech science에서 많이 사용되는 format 중 하나이다.(.sph 확장자를 갖는다.)

NIST(National Institute of Standards and Technology)에서 개발한 format이다. 따라서 NIST dataset에서 많이 사용되는 format이다.

SPHERE format


3.7.3 Other formats


3.8 Sound processing programs

설치는 다음 명령어를 통해 진행한다.

$ sudo apt install sox

설치는 다음 명령어를 통해 진행한다.

$ sudo apt install ffmpeg