forked from asticode/go-astideepspeech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deepspeech_wrap.h
60 lines (51 loc) · 2.4 KB
/
deepspeech_wrap.h
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
#ifdef __cplusplus
extern "C" {
#endif
typedef struct TokenMetadata {
const char* text;
const unsigned int timestep;
const float start_time;
} TokenMetadata;
typedef struct CandidateTranscript {
const TokenMetadata* const tokens;
const unsigned int num_tokens;
const double confidence;
} CandidateTranscript;
typedef struct Metadata {
const CandidateTranscript* const transcripts;
const unsigned int num_transcripts;
} Metadata;
typedef void* ModelWrapper;
ModelWrapper* New(const char* aModelPath, int* errorOut);
void Model_Close(ModelWrapper* w);
unsigned int Model_BeamWidth(ModelWrapper* w);
int Model_SetBeamWidth(ModelWrapper* w, unsigned int aBeamWidth);
int Model_SampleRate(ModelWrapper* w);
int Model_EnableExternalScorer(ModelWrapper* w, const char* aScorerPath);
int Model_DisableExternalScorer(ModelWrapper* w);
int Model_SetScorerAlphaBeta(ModelWrapper* w, float aAlpha, float aBeta);
char* Model_STT(ModelWrapper* w, const short* aBuffer, unsigned int aBufferSize);
Metadata* Model_STTWithMetadata(ModelWrapper* w, const short* aBuffer, unsigned int aBufferSize, unsigned int aNumResults);
typedef void* StreamWrapper;
StreamWrapper* Model_NewStream(ModelWrapper* w, int* errorOut);
void Stream_Discard(StreamWrapper* sw);
void Stream_FeedAudioContent(StreamWrapper* sw, const short* aBuffer, unsigned int aBufferSize);
char* Stream_IntermediateDecode(StreamWrapper* sw);
Metadata* Stream_IntermediateDecodeWithMetadata(StreamWrapper* sw, unsigned int aNumResults);
char* Stream_Finish(StreamWrapper* sw);
Metadata* Stream_FinishWithMetadata(StreamWrapper* sw, unsigned int aNumResults);
const CandidateTranscript* Metadata_Transcripts(Metadata* m);
unsigned int Metadata_NumTranscripts(Metadata* m);
void Metadata_Close(Metadata* m);
const TokenMetadata* CandidateTranscript_Tokens(CandidateTranscript* ct);
unsigned int CandidateTranscript_NumTokens(CandidateTranscript* ct);
double CandidateTranscript_Confidence(CandidateTranscript* ct);
const char* TokenMetadata_Text(TokenMetadata* tm);
unsigned int TokenMetadata_Timestep(TokenMetadata* tm);
float TokenMetadata_StartTime(TokenMetadata* tm);
void FreeString(char* s);
char* Version();
char* ErrorCodeToErrorMessage(int aErrorCode);
#ifdef __cplusplus
}
#endif