Skip to content

Commit

Permalink
LIA_SpkDet/SimpleSpkDetSystem: Added accessors for the decision thres…
Browse files Browse the repository at this point in the history
…hold.

The threshold is used in verifySpeaker() and identifySpeaker() to decide whether the tested voice is a match for the target model.
Previously, its value could only be set through the configuration file, and could not be retrieved directly (apart from parsing the configuration file). It can now be adjusted during the use of the system.
  • Loading branch information
tevamerlin committed Dec 6, 2018
1 parent 159deae commit c9e6b62
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions LIA_SpkDet/SimpleSpkDetSystem/include/SimpleSpkDetSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace alize
bool isUBMLoaded();
vector<String> speakerIDs();
void setOption(String opt, String optValue);
double decisionThreshold();
void setDecisionThreshold(double newValue);

void addAudio(uint32_t sampleCount, int16_t *samples); // for 16 bit linear PCM
void addAudio(uint32_t dataSize, void *data); // for other formats (following the format specified in the configuration file)
Expand Down Expand Up @@ -63,6 +65,7 @@ namespace alize
StatServer* _ss; ///< stat server
Config* _config; ///< configuration file
String _workdirPath; ///< working directory (for model storage + temp files)
double _decisionThreshold; ///< for score comparison in verifySpeaker and identifySpeaker
XLine lstFeatureFile; ///< list of feature files loaded in the feature server
vector<unsigned long> featureCounts; ///< size of each feature file in the feature server
struct ScoreAcc;
Expand Down
37 changes: 28 additions & 9 deletions LIA_SpkDet/SimpleSpkDetSystem/src/SimpleSpkDetSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,27 @@ void SimpleSpkDetSystem::setOption(String opt, String optValue) {
// Probably not worth the trouble.
}

/*! \fn void SimpleSpkDetSystem::decisionThreshold()
* \brief Returns the theshold used in verifySpeaker() and identifySpeaker()
* Only speakers with scores higher than the decision threshold will be
* considered a match for the target speaker.
*/
double SimpleSpkDetSystem::decisionThreshold() {
return _decisionThreshold;
}

/*! \fn void SimpleSpkDetSystem::setDecisionThreshold(double newValue)
* \brief Sets the theshold used in verifySpeaker() and identifySpeaker()
* Only speakers with scores higher than the decision threshold will be
* considered a match for the target speaker.
*
* \param[in] newValue the new decision threshold
*/
void SimpleSpkDetSystem::setDecisionThreshold(double newValue) {
_decisionThreshold = newValue;
}




/*! \fn void SimpleSpkDetSystem::resetAudio()
Expand Down Expand Up @@ -960,7 +981,6 @@ void SimpleSpkDetSystem::createSpeakerModel(String uId) {
* \return true if the features match the given speaker, otherwise false
*/
bool SimpleSpkDetSystem::verifySpeaker(String targetSpeakerId, float &resultingScore, bool withScoreAccumulation) {
double threshold=0.0;
int idx = _ms->getMixtureIndex(targetSpeakerId);
if(idx==-1)
throw Exception("Mixture not found: "+targetSpeakerId, __FILE__, __LINE__);
Expand Down Expand Up @@ -993,9 +1013,7 @@ bool SimpleSpkDetSystem::verifySpeaker(String targetSpeakerId, float &resultingS
}
}

if (_config->existsParam("threshold"))
threshold=(_config->getParam("threshold")).toDouble();
return (resultingScore > threshold);
return (resultingScore > _decisionThreshold);
}


Expand Down Expand Up @@ -1058,11 +1076,7 @@ bool SimpleSpkDetSystem::identifySpeaker(String &foundSpeakerId, float &resultin
foundSpeakerId = _ms->getMixture(bestScoreIndex).getId();
resultingScore = bestScore;

double threshold=0.0;
if (_config->existsParam("threshold"))
threshold=(_config->getParam("threshold")).toDouble();

return (bestScore > threshold);
return (bestScore > _decisionThreshold);
}


Expand Down Expand Up @@ -1147,6 +1161,11 @@ SimpleSpkDetSystem::SimpleSpkDetSystem(Config &config, String workdirPath) {
} else {
verboseLevel = verbose ? 1 : 0;
}

if (_config->existsParam("threshold"))
_decisionThreshold = (_config->getParam("threshold")).toDouble();
else
_decisionThreshold = 0.0;

_fs=new FeatureServer(*_config);
_ms=new MixtureServer(*_config);
Expand Down

0 comments on commit c9e6b62

Please sign in to comment.