io.agora.rtc

## Class AgoraAudioVadConfigV2

- java.lang.Object
- - io.agora.rtc.AgoraAudioVadConfigV2

-     public class AgoraAudioVadConfigV2
      extends java.lang.Object

  Configuration for the second generation VAD implementation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private float` | `activePercent` The percentage of active frames required in startRecognizeCount frames to enter speaking state.
    `private float` | `adaptiveRmsThresholdFactor` default to : 0.67.i.e 2/3
    `private boolean` | `enableAdaptiveRmsThreshold` enable adaptive rms threshold, default value is true
    `private float` | `inactivePercent` The percentage of inactive frames required in stopRecognizeCount frames to enter stop speaking state.
    `private int` | `preStartRecognizeCount` The number of audio frames to save before entering the start speaking state.
    `private int` | `startRecognizeCount` The number of audio frames required to confirm the speaking state.
    `private int` | `startRmsThreshold` rms: for rmsThreshold, the higher the value, the more sensitive to voice activity.
    `private int` | `startVoiceProb` voice prob: The lower the gate threshold, the higher the probability that a frame is judged as activity, which allows the start phase to begin earlier.
    `private int` | `stopRecognizeCount` The number of audio frames required to confirm the stop speaking state.
    `private int` | `stopRmsThreshold` rms: for rmsThreshold, the higher the value, the more sensitive to voice activity.
    `private int` | `stopVoiceProb` voice prob: The lower the gate threshold, the higher the probability that a frame is judged as activity, which allows the start phase to begin earlier.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgoraAudioVadConfigV2()` Creates a VAD configuration with default adaptive values.
    `AgoraAudioVadConfigV2(int preStartRecognizeCount, int startRecognizeCount, int stopRecognizeCount, float activePercent, float inactivePercent, int startVoiceProb, int stopVoiceProb, int startRmsThreshold, int stopRmsThreshold, boolean enableAdaptiveRmsThreshold, float adaptiveRmsThresholdFactor)` Creates a VAD configuration with custom thresholds.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `float` | `getActivePercent()` Returns the active percentage threshold.
    `float` | `getAdaptiveRmsThresholdFactor()` Returns the adaptive RMS threshold factor.
    `float` | `getInactivePercent()` Returns the inactive percentage threshold.
    `int` | `getPreStartRecognizeCount()` Returns the pre-start recognition frame count.
    `int` | `getStartRecognizeCount()` Returns the frames required to enter speaking state.
    `int` | `getStartRmsThreshold()` Returns the RMS threshold required to trigger start.
    `int` | `getStartVoiceProb()` Returns the voice probability required to trigger start.
    `int` | `getStopRecognizeCount()` Returns the frames required to leave speaking state.
    `int` | `getStopRmsThreshold()` Returns the RMS threshold required to trigger stop.
    `int` | `getStopVoiceProb()` Returns the voice probability required to trigger stop.
    `boolean` | `isEnableAdaptiveRmsThreshold()` Returns whether adaptive RMS thresholds are enabled.
    `void` | `setActivePercent(float activePercent)` Sets the active percentage threshold.
    `void` | `setAdaptiveRmsThresholdFactor(float adaptiveRmsThresholdFactor)` Sets the adaptive RMS threshold factor.
    `void` | `setEnableAdaptiveRmsThreshold(boolean enableAdaptiveRmsThreshold)` Enables or disables adaptive RMS thresholds.
    `void` | `setInactivePercent(float inactivePercent)` Sets the inactive percentage threshold.
    `void` | `setPreStartRecognizeCount(int preStartRecognizeCount)` Sets the pre-start recognition frame count.
    `void` | `setStartRecognizeCount(int startRecognizeCount)` Sets the frames required to enter speaking state.
    `void` | `setStartRmsThreshold(int startRmsThreshold)` Sets the RMS threshold required to trigger start.
    `void` | `setStartVoiceProb(int startVoiceProb)` Sets the voice probability required to trigger start.
    `void` | `setStopRecognizeCount(int stopRecognizeCount)` Sets the frames required to leave speaking state.
    `void` | `setStopRmsThreshold(int stopRmsThreshold)` Sets the RMS threshold required to trigger stop.
    `void` | `setStopVoiceProb(int stopVoiceProb)` Sets the voice probability required to trigger stop.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### preStartRecognizeCount

          private int preStartRecognizeCount

      The number of audio frames to save before entering the start speaking state. Default: 16 frames Range: [0, Integer.MAX_VALUE]

    - #### startRecognizeCount

          private int startRecognizeCount

      The number of audio frames required to confirm the speaking state. Default: 30 frames Range: [1, Integer.MAX_VALUE]

    - #### stopRecognizeCount

          private int stopRecognizeCount

      The number of audio frames required to confirm the stop speaking state. Default: 65 frames Range: [1, Integer.MAX_VALUE]

    - #### activePercent

          private float activePercent

      The percentage of active frames required in startRecognizeCount frames to enter speaking state. Default: 0.7 (70%) Range: [0.0, 1.0]

    - #### inactivePercent

          private float inactivePercent

      The percentage of inactive frames required in stopRecognizeCount frames to enter stop speaking state. Default: 0.5 (50%) Range: [0.0, 1.0]

    - #### startVoiceProb

          private int startVoiceProb

      voice prob: The lower the gate threshold, the higher the probability that a frame is judged as activity, which allows the start phase to begin earlier. Conversely, the higher the gate threshold, the lower the probability that a frame is judged as activity, and the higher the probability of being judged as inactivity, which allows the end phase to begin earlier. default: 70 range: [0, 100]

    - #### stopVoiceProb

          private int stopVoiceProb

      voice prob: The lower the gate threshold, the higher the probability that a frame is judged as activity, which allows the start phase to begin earlier. Conversely, the higher the gate threshold, the lower the probability that a frame is judged as activity, and the higher the probability of being judged as inactivity, which allows the end phase to begin earlier. default: 70 range: [0, 100]

    - #### startRmsThreshold

          private int startRmsThreshold

      rms: for rmsThreshold, the higher the value, the more sensitive to voice activity. In a quiet environment, it can be set to -70 (default); In a noisy environment, it can be set to a value between -50 and -40. default: -70 range: [-100, 0]

    - #### stopRmsThreshold

          private int stopRmsThreshold

      rms: for rmsThreshold, the higher the value, the more sensitive to voice activity. In a quiet environment, it can be set to -70 (default); In a noisy environment, it can be set to a value between -50 and -40. default: -70 range: [-100, 0]

    - #### enableAdaptiveRmsThreshold

          private boolean enableAdaptiveRmsThreshold

      enable adaptive rms threshold, default value is true

    - #### adaptiveRmsThresholdFactor

          private float adaptiveRmsThresholdFactor

      default to : 0.67.i.e 2/3

  - ### Constructor Detail

    - #### AgoraAudioVadConfigV2

          public AgoraAudioVadConfigV2()

      Creates a VAD configuration with default adaptive values.

    - #### AgoraAudioVadConfigV2

          public AgoraAudioVadConfigV2(int preStartRecognizeCount,
                                       int startRecognizeCount,
                                       int stopRecognizeCount,
                                       float activePercent,
                                       float inactivePercent,
                                       int startVoiceProb,
                                       int stopVoiceProb,
                                       int startRmsThreshold,
                                       int stopRmsThreshold,
                                       boolean enableAdaptiveRmsThreshold,
                                       float adaptiveRmsThresholdFactor)

      Creates a VAD configuration with custom thresholds.
      Parameters:
        `preStartRecognizeCount` - Frames buffered before speaking
        `startRecognizeCount` - Frames required to enter speaking state
        `stopRecognizeCount` - Frames required to leave speaking state
        `activePercent` - Percentage threshold for active state
        `inactivePercent` - Percentage threshold for inactive state
        `startVoiceProb` - Voice probability to trigger start
        `stopVoiceProb` - Voice probability to trigger stop
        `startRmsThreshold` - RMS threshold to trigger start
        `stopRmsThreshold` - RMS threshold to trigger stop
        `enableAdaptiveRmsThreshold` - Whether adaptive RMS thresholds are enabled
        `adaptiveRmsThresholdFactor` - Factor used when adaptive thresholds are enabled

  - ### Method Detail

    - #### getPreStartRecognizeCount

          public int getPreStartRecognizeCount()

      Returns the pre-start recognition frame count.
      Returns:
        Pre-start recognition count

    - #### setPreStartRecognizeCount

          public void setPreStartRecognizeCount(int preStartRecognizeCount)

      Sets the pre-start recognition frame count.
      Parameters:
        `preStartRecognizeCount` - Pre-start recognition count

    - #### getStartRecognizeCount

          public int getStartRecognizeCount()

      Returns the frames required to enter speaking state.
      Returns:
        Start recognition count

    - #### setStartRecognizeCount

          public void setStartRecognizeCount(int startRecognizeCount)

      Sets the frames required to enter speaking state.
      Parameters:
        `startRecognizeCount` - Start recognition count

    - #### getStopRecognizeCount

          public int getStopRecognizeCount()

      Returns the frames required to leave speaking state.
      Returns:
        Stop recognition count

    - #### setStopRecognizeCount

          public void setStopRecognizeCount(int stopRecognizeCount)

      Sets the frames required to leave speaking state.
      Parameters:
        `stopRecognizeCount` - Stop recognition count

    - #### getActivePercent

          public float getActivePercent()

      Returns the active percentage threshold.
      Returns:
        Active percentage

    - #### setActivePercent

          public void setActivePercent(float activePercent)

      Sets the active percentage threshold.
      Parameters:
        `activePercent` - Active percentage

    - #### getInactivePercent

          public float getInactivePercent()

      Returns the inactive percentage threshold.
      Returns:
        Inactive percentage

    - #### setInactivePercent

          public void setInactivePercent(float inactivePercent)

      Sets the inactive percentage threshold.
      Parameters:
        `inactivePercent` - Inactive percentage

    - #### getStartVoiceProb

          public int getStartVoiceProb()

      Returns the voice probability required to trigger start.
      Returns:
        Start voice probability

    - #### setStartVoiceProb

          public void setStartVoiceProb(int startVoiceProb)

      Sets the voice probability required to trigger start.
      Parameters:
        `startVoiceProb` - Start voice probability

    - #### getStopVoiceProb

          public int getStopVoiceProb()

      Returns the voice probability required to trigger stop.
      Returns:
        Stop voice probability

    - #### setStopVoiceProb

          public void setStopVoiceProb(int stopVoiceProb)

      Sets the voice probability required to trigger stop.
      Parameters:
        `stopVoiceProb` - Stop voice probability

    - #### getStartRmsThreshold

          public int getStartRmsThreshold()

      Returns the RMS threshold required to trigger start.
      Returns:
        Start RMS threshold

    - #### setStartRmsThreshold

          public void setStartRmsThreshold(int startRmsThreshold)

      Sets the RMS threshold required to trigger start.
      Parameters:
        `startRmsThreshold` - Start RMS threshold

    - #### getStopRmsThreshold

          public int getStopRmsThreshold()

      Returns the RMS threshold required to trigger stop.
      Returns:
        Stop RMS threshold

    - #### setStopRmsThreshold

          public void setStopRmsThreshold(int stopRmsThreshold)

      Sets the RMS threshold required to trigger stop.
      Parameters:
        `stopRmsThreshold` - Stop RMS threshold

    - #### isEnableAdaptiveRmsThreshold

          public boolean isEnableAdaptiveRmsThreshold()

      Returns whether adaptive RMS thresholds are enabled.
      Returns:
        `true` if adaptive thresholds are enabled; otherwise `false`

    - #### setEnableAdaptiveRmsThreshold

          public void setEnableAdaptiveRmsThreshold(boolean enableAdaptiveRmsThreshold)

      Enables or disables adaptive RMS thresholds.
      Parameters:
        `enableAdaptiveRmsThreshold` - `true` to enable adaptive thresholds

    - #### getAdaptiveRmsThresholdFactor

          public float getAdaptiveRmsThresholdFactor()

      Returns the adaptive RMS threshold factor.
      Returns:
        Adaptive RMS factor

    - #### setAdaptiveRmsThresholdFactor

          public void setAdaptiveRmsThresholdFactor(float adaptiveRmsThresholdFactor)

      Sets the adaptive RMS threshold factor.
      Parameters:
        `adaptiveRmsThresholdFactor` - Adaptive RMS factor

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`