Add Android demo for speaker recognition (#536)

See pre-built Android APKs at 
https://k2-fsa.github.io/sherpa/onnx/speaker-identification/apk.html
This commit is contained in:
Fangjun Kuang
2024-01-23 16:50:52 +08:00
committed by GitHub
parent 626775e5e2
commit bbd7c7fc18
73 changed files with 3022 additions and 6 deletions

View File

@@ -7,6 +7,7 @@
#include <memory>
#include <string>
#include <vector>
namespace sherpa_onnx {
@@ -26,6 +27,19 @@ class SpeakerEmbeddingManager {
*/
bool Add(const std::string &name, const float *p) const;
/** Add a list of embeddings of a speaker.
*
* @param name Name of the speaker
* @param embedding_list A list of embeddings. Each entry should be of size
* `dim`. The average of the list is the final
* embedding.
* @return Return true if added successfully. Return false if it failed.
* At present, the only reason for a failure is that there is already
* a speaker with the same `name`.
*/
bool Add(const std::string &name,
const std::vector<std::vector<float>> &embedding_list) const;
/* Remove a speaker by its name.
*
* @param name Name of the speaker to remove.
@@ -60,8 +74,16 @@ class SpeakerEmbeddingManager {
*/
bool Verify(const std::string &name, const float *p, float threshold) const;
// Return true if the given speaker already exists; return false otherwise.
bool Contains(const std::string &name) const;
int32_t NumSpeakers() const;
int32_t Dim() const;
// Return a list of speaker names
std::vector<std::string> GetAllSpeakers() const;
private:
class Impl;
std::unique_ptr<Impl> impl_;