0.Integration to prepare
Download Android Vad Demo code
Download iOS Vad Demo code
Supported operating environment
- Android API Level >=14 (Android 4.0 above) Java 1.7+
- iOS 6.0 and above
Supported Audio Formats
wav/pcm, mono、16bite、16Khz Sampling Rate
SDK files
Download iOS vad sdk
Download Android vad sdk
SDK package content description
| Platform |
Content |
| Android |
ChivoxVAD.jarlibchivox_vad.sovad.0.13.bin |
| iOS |
libchivox_vad.achivox_vad.hvad.0.13.bin |
Overall Process

1.Create instance
1.1 Function prototype
struct chivox_vad *chivox_vad_new(const char *cfg);
1.2 Function
- Create a vad engine instance, and create a global instance when the product starts or enters the recording interface. Subsequent recordings can reuse the vad instance.
1.3 Argument
| Argument |
Description |
| cfg |
Vad engine related configuration, in string format, a string of JSON objects. Please refer to the cfg parameter description below for details. |
1.4 cfg Parameter Description
| Name |
Type |
Option |
Description |
| vad |
object |
true |
Sound detection function |
| - res |
string |
true |
Vad resource path. |
| - speechLowSeek |
int |
false |
Sensitivity, unit 20ms, set to N (default 15), it means that 20*N milliseconds after speaking stop is judged as the end |
| - sampleRate |
int |
false |
Audio sampleRate,unit Hz |
1.5 Return value description
| Returns a value of type Int |
Description |
| chivox_vad pointer to object |
success |
| NULL |
Fail |
2.Launch request
2.1 Function prototype
int chivox_vad_start(struct chivox_vad *vad, char *param);
2.2 Function
- Start detection
After calling start, stop or cancel must be called accordingly to ensure that the occupied resources are released.
2.3 Argument
| Argument |
Description |
| vad |
chivox_vad instance |
| param |
Vad engine related configuration, in string format. Please refer to the param parameter description below for details. |
2.4 Param Parameter Description
| Name |
Type |
Option |
Description |
| vad |
object |
false |
Sound detection function |
| - refDuration |
int |
false |
Set vad delay effective time (unit: seconds), block VAD within a few seconds of starting recording |
2.5 Return value description
| Returns a value of type Int |
Description |
| 0 |
success |
| Other |
fail |
3.Send audio data
3.1 Function prototype
int chivox_vad_feed(struct chivox_vad *vad, const void *data, int size);
3.2 Function
- Send audio data to the vad engine
3.3 Argument
| Argument |
Description |
| vad |
chivox_vad instance |
| data |
Audio data |
| size |
The length of audio data, unit: bytes |
3.4 Return value description
| Returns a value of type Int |
Description |
| 0 |
success |
| Other |
fail |
4.1 VAD status acquisition
4.1.1 Function prototype
int chivox_vad_state(struct chivox_vad *vad);
4.1.2 Function
- Get the audio status after the last call to chivox_vad_feed.
4.1.3 Argument
| Argument |
Description |
| vad |
chivox_vad instance |
4.1.4 Return value description
| Returns a value of type Int |
Description |
| chivox_vad_state_sil/0 |
mute state |
| chivox_vad_state_speech/1 |
Start of voice activity detected |
| chivox_vad_state_end/2 |
End of voice activity detected |
| chivox_vad_state_error/-1 |
An error occurred, the reason can be obtained by get_last_chivox_vad_errno() or chivox_vad_strerror(get_last_chivox_vad_errno())Possible reason:1. CHIVOX_VAD_ERROR_INVALID_PARAMETER:The vad parameter is NULL;2. CHIVOX_VAD_ERROR_WRONG_ORDER:has not started yet, or has ended last time;3. CHIVOX_VAD_ERROR_CURRENT_NO_RESULT:The audio data has not been passed to the vad engine, and there is no result. |
4.2 Sound intensity acquisition
4.2.1 Function prototype
float chivox_vad_sound_intensity(struct chivox_vad *vad);
4.2.2 Function
- Get the sound intensity of the last input audio data.
4.2.3 Argument
| Argument |
Description |
| vad |
chivox_vad instance |
4.2.4 Return value description
| Returns a value of type float |
Description |
| 0 - 100 |
sound intensity |
| < 0 |
fail |
5. Stop request
5.1 Function prototype
int chivox_vad_stop(struct chivox_vad *vad);
5.2 Function
5.3 Argument
| Argument |
Description |
| vad |
chivox_vad instance |
5.4 Return value description
| Returns a value of type Int |
Description |
| 0 |
success |
| Other |
fail |
6. Delete instance
6.1 Function prototype
int chivox_vad_delete(struct chivox_vad *vad);
6.2 Function
- delete a created instance of chivox_vad
6.3 Argument
| Argument |
Description |
| vad |
chivox_vad instance |
6.4 Return value Description
| Returns a value of type Int |
Description |
| 0 |
success |
| Other |
fail |
7.Get error code
7.1 Function prototype
int get_last_chivox_vad_errno();
7.2 Function
- Returns the error code of last call
7.3 Return value description
| Returns a value of type Int |
Description |
| CHIVOX_VAD_ERROR_NO_ERROR = 0 |
no errors |
| CHIVOX_VAD_ERROR_UNKNOWN = 1 |
Errors that cannot yet be classified |
| CHIVOX_VAD_ERROR_INVALID_PARAMETER = 60000 |
Invalid parameter passed in |
| CHIVOX_VAD_ERROR_PARAMETER_NOT_JSON = 60001 |
The incoming string parameter is not JSON |
| CHIVOX_VAD_ERROR_KERNEL_ERROR = 60008 |
kernel error |
| CHIVOX_VAD_ERROR_WRONG_ORDER = 60011 |
The calling sequence is wrong, or it cannot be called temporarily at this time, other functions should be called first |
| CHIVOX_VAD_ERROR_INNER_ERROR = 60019 |
Internal sdk error, usually insufficient memory, but also insufficient other system resources |
| CHIVOX_VAD_ERROR_JSON_PARAMETER_ERROR = 60023 |
The required item in the JSON parameter is not filled in or the type is wrong |
| CHIVOX_VAD_ERROR_RESOURCE_ERROR = 60024 |
The resource written does not exist or does not have permission |
| CHIVOX_VAD_ERROR_CURRENT_NO_RESULT = 60025 |
There are currently no results, call chivox_vad_feed and try again |
8. Get error message
8.1 Function prototype
const char *chivox_vad_strerror(int chivox_vad_errno);
8.2 Function
- Return an error message. The original text cannot be modified/released. If you need to modify it, you can copy it through strcpy and then modify it.
8.3 Argument
| Argument |
Description |
| chivox_vad_errno |
error code. It can be the return value after an interface is called, or it can be directly input; the defined error constant value such as CHIVOX_VAD_ERROR_NO_ERROR. |