Repository navigation
Expand file tree
/
Copy pathapi.h
More file actions
69 lines (54 loc) · 2.25 KB
/
Copy pathapi.h
File metadata and controls
69 lines (54 loc) · 2.25 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// C API
#ifndef TTS_API_H
#define TTS_API_H
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef TTS_SHARED
#if defined(_WIN32) && !defined(__MINGW32__)
#ifdef TTS_BUILD
#define TTS_API __declspec(dllexport)
#else
#define TTS_API __declspec(dllimport)
#endif
#else
#define TTS_API __attribute__((visibility("default")))
#endif
#else
#define TTS_API
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
typedef bool (*tts_synthesis_callback)(void *user_data, const float *audio_data, const size_t audio_size); // return true to continue decoding, false to stop
typedef struct tts_context tts_context;
TTS_API struct tts_context *tts_create_context();
TTS_API void tts_free_context(struct tts_context *ctx);
TTS_API bool tts_init_voice_feature_extraction(tts_context *ctx,
const char *audio_tokenizer_model_path);
TTS_API bool tts_init_text_to_speech(tts_context *ctx,
const char *audio_detokenizer_model_path,
const char *transformer_model_path,
const char *tokenizer_path,
const uint32_t transformer_n_ctx,
const size_t overlapped_semantic_tokens);
TTS_API void tts_deinit_voice_feature_extraction(tts_context *ctx);
TTS_API void tts_deinit_text_to_speech(tts_context *ctx);
// free after use
TTS_API int32_t *tts_extract_voice_features(tts_context *ctx,
const float *audio_data,
const size_t audio_size,
size_t *voice_features_size);
TTS_API void tts_text_to_speech(tts_context *ctx,
const char *text,
const int32_t *voice_features, // array of size 32
const size_t n_sec, // max number of seconds to generate
void *user_data,
tts_synthesis_callback callback);
#ifdef __cplusplus
}
#endif
#endif // TTS_API_H