unity_lib.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "ggml/ggml.h"
  2. #include "ggml/ggml-alloc.h"
  3. #include "math.h"
  4. #include "model_loader.h"
  5. #include "fairseq2.h"
  6. #include <thread>
  7. #include <cassert>
  8. #include <cmath>
  9. #include <cstdio>
  10. #include <cstring>
  11. #include <fstream>
  12. #include <map>
  13. #include <string>
  14. #include <vector>
  15. #include <iostream>
  16. #include <cstdlib>
  17. struct Result {
  18. std::vector<std::string> transcription;
  19. std::vector<float> word_confidence_scores;
  20. std::unordered_map<std::string, float> lid_scores;
  21. int err;
  22. };
  23. struct ggml_cgraph * unity_speech_encoder(
  24. fairseq2_model& model,
  25. struct ggml_tensor * speech_input);
  26. Hypothesis* unity_decode(
  27. fairseq2_model& model,
  28. const SequenceGeneratorOptions& opts,
  29. int tgt_lang_idx,
  30. ggml_tensor* encoder_output,
  31. int n_threads
  32. );
  33. extern "C" fairseq2_model unity_init_model(const char* model_path);
  34. extern "C" Result unity_eval(fairseq2_model model, std::vector<float> data, SequenceGeneratorOptions opts, std::string tgt_lang, int n_threads, int memory_gb);