Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a audio frame contain?

Tags:

I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone.

My thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess.

So after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n):

Reads and returns at most n frames of audio, as a string of bytes.

What do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.

like image 706
Jason94 Avatar asked Oct 18 '10 06:10

Jason94


People also ask

How many audio samples are in a frame?

A frame consists of exactly one sample per channel. If there is only one channel (Mono sound) a frame is simply a single sample. If the sound is stereo, each frame consists of two samples, etc. is 8 bits, and we're handling mono sound, the frame size is one byte.

What does audio consist of?

The 3 elements that make up audio. In everyday life, the word 'audio' is often used casually to refer to speakers and other related components. However, audio can roughly be divided into 3 primary mechanisms (devices): player, amplifier, and speaker.

What is a frame in a WAV file?

A frame consists of samples. There is one sample per channel, per frame. Every wav file has a sample width, or, the number of bytes per sample. Typically this is either 1 or 2 bytes. The wav module supplies more convenient access to this data.

Is frame and sample same?

Sampling Frame vs.A sampling frame is a list of things that you draw a sample from. A sample space is a list of all possible outcomes for an experiment.


2 Answers

An audio frame, or sample, contains amplitude (loudness) information at that particular point in time. To produce sound, tens of thousands of frames are played in sequence to produce frequencies.

In the case of CD quality audio or uncompressed wave audio, there are around 44,100 frames/samples per second. Each of those frames contains 16-bits of resolution, allowing for fairly precise representations of the sound levels. Also, because CD audio is stereo, there is actually twice as much information, 16-bits for the left channel, 16-bits for the right.

When you use the sound module in python to get a frame, it will be returned as a series of hexadecimal characters:

  • One character for an 8-bit mono signal.
  • Two characters for 8-bit stereo.
  • Two characters for 16-bit mono.
  • Four characters for 16-bit stereo.

In order to convert and compare these values you'll have to first use the python wave module's functions to check the bit depth and number of channels. Otherwise, you'll be comparing mismatched quality settings.

like image 179
Soviut Avatar answered Oct 06 '22 18:10

Soviut


A simple byte-by-byte comparison has almost no chance of a successful match, even with some tolerance thrown in. Voice-pattern recognition is a very complex and subtle problem that is still the subject of much research.

like image 39
Marcelo Cantos Avatar answered Oct 06 '22 17:10

Marcelo Cantos