Upload cpp/ax650/include/ax_asr_api.h with huggingface_hub
Browse files
cpp/ax650/include/ax_asr_api.h
CHANGED
|
@@ -16,6 +16,15 @@ extern "C" {
|
|
| 16 |
|
| 17 |
#define AX_ASR_API __attribute__((visibility("default")))
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
// Supported asr
|
| 21 |
enum AX_ASR_TYPE_E {
|
|
@@ -113,10 +122,56 @@ AX_ASR_API int AX_ASR_RunPCM(AX_ASR_HANDLE handle,
|
|
| 113 |
int num_samples,
|
| 114 |
int sample_rate,
|
| 115 |
const char* language,
|
| 116 |
-
char** result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
#ifdef __cplusplus
|
| 119 |
}
|
| 120 |
#endif
|
| 121 |
|
| 122 |
-
#endif // _AX_ASR_API_H_
|
|
|
|
| 16 |
|
| 17 |
#define AX_ASR_API __attribute__((visibility("default")))
|
| 18 |
|
| 19 |
+
enum AX_ASR_STATUS_E {
|
| 20 |
+
AX_ASR_SUCCESS = 0,
|
| 21 |
+
AX_ASR_ERR_INVALID_ARGUMENT = -1,
|
| 22 |
+
AX_ASR_ERR_INIT_FAILED = -2,
|
| 23 |
+
AX_ASR_ERR_AUDIO_LOAD_FAILED = -3,
|
| 24 |
+
AX_ASR_ERR_RUN_FAILED = -4,
|
| 25 |
+
AX_ASR_ERR_NO_MEMORY = -5,
|
| 26 |
+
AX_ASR_ERR_STREAM_NOT_SUPPORTED = -6
|
| 27 |
+
};
|
| 28 |
|
| 29 |
// Supported asr
|
| 30 |
enum AX_ASR_TYPE_E {
|
|
|
|
| 122 |
int num_samples,
|
| 123 |
int sample_rate,
|
| 124 |
const char* language,
|
| 125 |
+
char** result);
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* @brief Free transcription text returned by AX_ASR_RunFile/AX_ASR_RunPCM.
|
| 129 |
+
*
|
| 130 |
+
* @param result Buffer returned through the result output parameter.
|
| 131 |
+
*/
|
| 132 |
+
AX_ASR_API void AX_ASR_Free(char* result);
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* @brief Initialize streaming recognition state.
|
| 136 |
+
* Must be called before AX_ASR_StreamFeed.
|
| 137 |
+
* Clears accumulated audio features and resets partial results.
|
| 138 |
+
*/
|
| 139 |
+
AX_ASR_API int AX_ASR_StreamInit(AX_ASR_HANDLE handle);
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* @brief Feed a chunk of audio data for streaming recognition.
|
| 143 |
+
* Accumulates features and runs incremental CTC inference.
|
| 144 |
+
*
|
| 145 |
+
* @param handle ASR context handle
|
| 146 |
+
* @param pcm_data Float32 mono PCM data, range [-1.0, 1.0]
|
| 147 |
+
* @param num_samples Number of samples in this chunk
|
| 148 |
+
* @param sample_rate Sample rate of the audio (resampled to 16kHz internally)
|
| 149 |
+
*/
|
| 150 |
+
AX_ASR_API int AX_ASR_StreamFeed(AX_ASR_HANDLE handle,
|
| 151 |
+
float* pcm_data, int num_samples, int sample_rate);
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* @brief Get the current partial streaming result.
|
| 155 |
+
* The returned string is allocated internally and freed on next StreamFeed or StreamReset.
|
| 156 |
+
*
|
| 157 |
+
* @param handle ASR context handle
|
| 158 |
+
* @param result Pointer to receive partial transcription text. DO NOT free externally.
|
| 159 |
+
*/
|
| 160 |
+
AX_ASR_API int AX_ASR_StreamResult(AX_ASR_HANDLE handle, const char** result);
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* @brief Flush the remaining streaming tail (dedicated streaming model only).
|
| 164 |
+
* Call this after feeding all audio to get the final partial result.
|
| 165 |
+
*/
|
| 166 |
+
AX_ASR_API int AX_ASR_StreamFinish(AX_ASR_HANDLE handle);
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* @brief Reset streaming state (equivalent to StreamInit).
|
| 170 |
+
*/
|
| 171 |
+
AX_ASR_API int AX_ASR_StreamReset(AX_ASR_HANDLE handle);
|
| 172 |
|
| 173 |
#ifdef __cplusplus
|
| 174 |
}
|
| 175 |
#endif
|
| 176 |
|
| 177 |
+
#endif // _AX_ASR_API_H_
|