-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfreesr-example.cc
More file actions
47 lines (36 loc) · 1.35 KB
/
freesr-example.cc
File metadata and controls
47 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Speaker recognition example for FreeSR
#include "speaker_recognizer.h"
#include <iostream>
#include <string>
#include <vector>
int main(int argc, char** argv)
{
SpeakerRecognizer spk(16000);
bool ret = spk.Init();
if(!ret)
{
std::cout << "Failed to init ..." << std::endl;
return -1;
}
std::cout << "Recognize Speaker Example by FreeSR ..." << std::endl;
double confidence = spk.Compare("BAC009S0002W0123.wav", "BAC009S0002W0122.wav");
std::cout << "Compare similarity: " << confidence << std::endl;
ret = spk.RegisterSpeaker("BAC009S0002W0122.wav", "S0002");
if(!ret)
{
std::cout << "Failed to register ..." << std::endl;
return -1;
}
ret = spk.RegisterSpeaker("BAC009S0003W0121.wav","S0003");
if(!ret)
{
std::cout << "Failed to register ..." << std::endl;
return -1;
}
std::cout << "Register Speaker Total: " << spk.GetRegisterSpeakerCount() << std::endl;
RecInfo rec = spk.RecognizeSpeaker("BAC009S0002W0123.wav");
std::cout << "BAC009S0002W0123 Recognize result: " << rec.result << " | confidence: "<< rec.confidence << std::endl;
rec = spk.RecognizeSpeaker("BAC009S0003W0122.wav");
std::cout << "BAC009S0003W0122 Recognize result: " << rec.result << " | confidence: "<< rec.confidence << std::endl;
return 0;
}