Documentation ¶
Overview ¶
Package fingerprint provides functionality to calculate, compare and analyse acoustic fingerprints of raw audio data. According to Wikipedia, acoustic fingerprint is a condensed digital summary, deterministically generated from an audio signal, that can be used to identify an audio sample or quickly locate similar items in an audio database.
Installation
go get https://github.com/go-fingerprint/fingerprint
You should also install any package containing the implementation of any fingerprinting algoritms. Currently only bindings to chromaprint library are supported.
go get https://github.com/go-fingerprint/gochroma
Usage
reader, _ := os.Open("test.raw") fpcalc := chromaprint.New(chromaprint.AlgorithmDefault) defer fpcalc.Close() fprint, _ := fpcalc.Fingerprint( fingerprint.RawInfo{ Src: reader, Channels: 2, Rate: 44100, MaxSeconds: 120, }) // do anything with fingerprint...
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrLength = errors.New(`fingerprint: unable to compare fingerprints with
different length`)
)
ErrLength describes a error that occurs when trying to compare fingerprints with different length.
Functions ¶
func Compare ¶
Compare returns a number that indicates how two fingerprints are similar to each other as a value from 0 to 1. Usually two fingerprints can be considered identical when the score is greater or equal than 0.95.
func ImageDistance ¶
ImageDistance returns black-and white image.Image with graphical representation of distance between fingerprints.
Types ¶
type Calculator ¶
type Calculator interface { Fingerprint(i RawInfo) (fprint string, err error) RawFingerprint(i RawInfo) (fprint []int32, err error) }
Calculator is an interface type that can calculate acoustic fingerprints and return as raw int32 data or as base64-encoded string.
type RawInfo ¶
type RawInfo struct { // Reader connected with the audio data stream Src io.Reader // Number of channels of audio stream Channels uint // Sampling rate of input audio data, e.g. 44100 Rate uint // Maximum number of seconds that will be taken // from the audio stream MaxSeconds uint }
A RawInfo holds information about raw audio data.