Class SNRComputer

All Implemented Interfaces:
AutoCloseable

public class SNRComputer extends VoiceSdkNativePeer
Calculates average Signal-to-Noise ratio, dB in the specified audio data.

This class serves as gateway to native Voice SDK implementation and allocates resources on native heap. To release the allocated memory, AutoCloseable.close() method should be invoked when the instance is no longer needed.

Any method that delegates to native call may throw VoiceSdkEngineException

  • Constructor Summary

    Constructors
    Constructor
    Description
    SNRComputer(String initPath)
    Initializes the instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    compute(byte[] pcm16Bytes, int sampleRate)
    Calculates SNR over the specified audio buffer provided as an array of PCM16 samples.
    float
    compute(float[] floatSamples, int sampleRate)
    Calculates SNR over the specified audio buffer provided as an array of normalized float values.
    float
    compute(short[] pcm16Samples, int sampleRate)
    Calculates SNR over the specified audio buffer provided as an array of PCM16 samples.
    float
    compute(String audioFile)
    Calculates SNR over the specified audio record.

    Methods inherited from class net.idrnd.voicesdk.common.VoiceSdkNativePeer

    close, equals, hashCode

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • compute

      public float compute(byte[] pcm16Bytes, int sampleRate)
      Calculates SNR over the specified audio buffer provided as an array of PCM16 samples.
      Parameters:
      pcm16Bytes - Array of little-endian PCM16 audio bytes
      sampleRate - audio stream sampling rate, Hz
      Returns:
      average SNR, dB
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • compute

      public float compute(short[] pcm16Samples, int sampleRate)
      Calculates SNR over the specified audio buffer provided as an array of PCM16 samples.
      Parameters:
      pcm16Samples - Array of PCM16 audio samples
      sampleRate - audio stream sampling rate, Hz
      Returns:
      average SNR, dB
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • compute

      public float compute(float[] floatSamples, int sampleRate)
      Calculates SNR over the specified audio buffer provided as an array of normalized float values.
      Parameters:
      floatSamples - Array of float audio samples (in [-1, 1] range)
      sampleRate - audio stream sampling rate, Hz
      Returns:
      average SNR, dB
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • compute

      public float compute(String audioFile)
      Calculates SNR over the specified audio record.
      Parameters:
      audioFile - Path to the audio file
      Returns:
      average SNR, dB
      Throws:
      VoiceSdkEngineException - wraps native exceptions