| 74 | } |
| 75 | |
| 76 | bool generate_audio(int n_threads, bark_context *bctx, std::string text, std::string dest) { |
| 77 | if (!bark_generate_audio(bctx, text.c_str(), n_threads)) { |
| 78 | fprintf(stderr, "%s: An error occured. If the problem persists, feel free to open an issue to report it.\n", __func__); |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | const float *audio_data = bark_get_audio_data(bctx); |
| 83 | if (audio_data == NULL) { |
| 84 | fprintf(stderr, "%s: Could not get audio data\n", __func__); |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | const int audio_arr_size = bark_get_audio_data_size(bctx); |
| 89 | |
| 90 | std::vector<float> audio_arr(audio_data, audio_data + audio_arr_size); |
| 91 | |
| 92 | write_wav_on_disk(audio_arr, dest); |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | int main(int argc, char **argv) { |
| 97 | ggml_time_init(); |
no test coverage detected