Govpr--golang implementation of the GMM-UBM algorithm for speaker recognition (voice recognition) engine

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Brief introduction

GOVPR is a Golang implementation based on the GMM-UBM speaker recognition engine (voice recognition), which can be used for speech authentication and identification scenarios.
Currently only support Chinese digital voice, speech format is WAV format (bitrate 16000,16bits, mono)

Installation

Go get GITHUB.COM/LIUXP0827/GOVPR

Example

The following is a simple example. Can jump to example
For a detailed example, the voice in the example is a 8-digit number. A score is obtained after voice verification, and a threshold value can be set to determine if the voice is a registered trainer.

Package Mainimport ("GITHUB.COM/LIUXP0827/GOVPR" "Github.com/liuxp0827/govpr/log" "Github.com/liuxp0827/govpr/wa Veio "Io/ioutil") type engine struct {vprengine *govpr.        Vprengine}func newengine (samplerate, Delsilrange int, ubmfile, usermodelfile string) *engine {return &engine{ VPRENGINE:GOVPR. Newvprengine (Samplerate, Delsilrange, Ubmfile, Usermodelfile),}}func (this *engine) Destroyengine () {This.vprEngin  E = Nil}func (this *engine) Trainspeech (buffers [][]byte) error {var err error count: = Len (buffers) for I: = 0; I < count; i++ {err = This.vprEngine.AddTrainBuffer (Buffers[i]) if err! = Nil {log. Error (ERR) return err}} defer This.vprEngine.ClearTrainBuffer () defer this.vprEngine.ClearAll Buffer () Err = This.vprEngine.TrainModel () if err! = Nil {log. Error (ERR) return err} return Nil}func (this *engine) recspeech (buffer []byte) error {err: = THIS.VPRengine.addverifybuffer (buffer) defer this.vprEngine.ClearVerifyBuffer () if err! = Nil {log. Error (ERR) return err} err = This.vprEngine.VerifyModel () if err! = Nil {log. Error (ERR) return err} score: = This.vprEngine.GetScore () log. Infof ("VPR score:%f", score) return Nil}func main () {log. SetLevel (log. Leveldebug) Vprengine: = Newengine (16000, 50, ".. /UBM/UBM "," Model/test.dat ") trainlist: = []string{" Wav/train/01_32468975.wav "," WAV/TRAIN/02_58769423.W AV "," wav/train/03_59682734.wav "," Wav/train/04_64958273.wav "," Wav/train/05_65432978.wav ",} t  Rainbuffer: = Make ([][]byte, 0) for _, File: = Range trainlist {buf, err: = Loadwavedata (file) if err! = Nil {log. Error (ERR) return} Trainbuffer = Append (Trainbuffer, buf)} verifybuffer, err: = Waveio.wa Veload ("Wav/verify/34986527.wav") if err! = Nil {log. Error (Err) return} vprengine.trainspeech (Trainbuffer) Vprengine.recspeech (verifybuffer)}func loadwavedata (File str ing) ([]byte, error) {data, err: = Ioutil.    ReadFile (file) if err! = Nil {return nil, err}//Remove. wav Header info, bits data = data[44:] Return data, nil}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.