Updated on 2022-02-22 GMT+08:00

Audio Collector

This API is used to construct an audio collector to obtain audio data from local microphones or audio files.

  • API calling

    1.0.8 or later

    hilens.AudioCapture(file_path)

    1.1.2 or later

    hilens.AudioCapture(sample_rate, bit_width, nSamples, sound_mode)

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Type

    Description

    file_path

    No

    Character string

    Audio file path. Audio data is obtained from the file to construct a collector for audio file data.

    sample_rate

    No

    Integer

    Sampling rate, which is the recording parameter of the local microphone. The default value is AUDIO_SAMPLE_RATE_44100. Possible values are as follows:

    AUDIO_SAMPLE_RATE_8000

    AUDIO_SAMPLE_RATE_12000

    AUDIO_SAMPLE_RATE_11025

    AUDIO_SAMPLE_RATE_16000

    AUDIO_SAMPLE_RATE_22050

    AUDIO_SAMPLE_RATE_24000

    AUDIO_SAMPLE_RATE_32000

    AUDIO_SAMPLE_RATE_44100

    AUDIO_SAMPLE_RATE_48000

    AUDIO_SAMPLE_RATE_64000

    AUDIO_SAMPLE_RATE_96000

    bit_width

    No

    Integer

    Bit width, which is the recording parameter of the local microphone. The default value is AUDIO_BIT_WIDTH_16.

    nSamples

    No

    Integer

    Number of audio sampling points in each frame, which is the recording parameter of the local microphone. The default value is 1024, and the value range is [80, 2048].

    sound_mode

    No

    Integer

    Audio channel mode, which is the recording parameter of the local microphone. The default value is AUDIO_SOUND_MODE_MONO. Possible values are as follows:

    AUDIO_SOUND_MODE_MONO

    AUDIO_SOUND_MODE_STEREO

    • There is only one local microphone. Different recording parameters cannot be set for multiple processes. The parameters set earlier take effect.
  • Return value
    • Audio data collector
    • If the construction fails, "CreateError" is reported. You can view skill logs.