-
Notifications
You must be signed in to change notification settings - Fork 50
/
test-forward-encodec.cpp
47 lines (37 loc) · 1.46 KB
/
test-forward-encodec.cpp
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
#include <cstdio>
#include <string>
#include <random>
#include <vector>
#include "bark.h"
#include "common.h"
static const std::vector<std::string> test_data = {
"./data/encodec/test_pass_encodec_1.bin", // prompt: El hombre que se levanta es aún más grande que el que no ha caído.
"./data/encodec/test_pass_encodec_2.bin", // prompt: ♪ Heal the world, Make it a better place, For you and for me, and the entire human race ♪
"./data/encodec/test_pass_encodec_3.bin", // prompt: En été, mieux vaut suer que trembler.
};
int main() {
const std::string fname = "../ggml_weights/ggml_weights_codec.bin";
encodec_model model;
if (encodec_model_load(fname, model) > 0) {
fprintf(stderr, "%s: invalid model file '%s'\n", __func__, fname.c_str());
return 1;
}
bark_codes tokens;
audio_arr_t gt_audio_arr, audio_arr;
for (int i = 0; i < (int) test_data.size(); i++) {
tokens.clear();
gt_audio_arr.clear();
audio_arr.clear();
std::string path = test_data[i];
load_test_data(path, tokens, gt_audio_arr);
audio_arr_t audio_arr = bark_forward_encodec(transpose(tokens), model);
printf("\n");
printf("%s: %s\n", __func__, path.c_str());
if (!run_test(gt_audio_arr, audio_arr)) {
printf("%s: test %d failed.\n", __func__, i+1);
} else {
printf("%s: test %d passed.\n", __func__, i+1);
}
}
return 0;
}