Skip to content

Commit

Permalink
fix: return constant matches
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Jul 10, 2024
1 parent d1a50a1 commit 7d2341d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sherpa-onnx/c-api/c-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1266,21 +1266,22 @@ SherpaOnnxSpeakerEmbeddingManagerGetBestMatches(
return nullptr;
}

auto *result = new SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult();
result->count = matches.size();
result->matches =
auto resultMatches =
new SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch[matches.size()];

for (int i = 0; i < matches.size(); ++i) {
result->matches[i].score = matches[i].score;
resultMatches[i].score = matches[i].score;

char *name = new char[matches[i].name.size() + 1];
std::copy(matches[i].name.begin(), matches[i].name.end(), name);
name[matches[i].name.size()] = '\0';

result->matches[i].name = name;
resultMatches[i].name = name;
}

auto *result = new SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult();
result->count = matches.size();
result->matches = resultMatches;

return result;
}

Expand Down

0 comments on commit 7d2341d

Please sign in to comment.