Skip to content

VoiceRecorder.Builder

Builder for VoiceRecorder.Config.

Public Methods

public init()

Constructor of the class.

@discardableResult
public func setFs(_ fs: Int) -> Builder

Sets the frequency of sampling.

  • Parameters:

    • fs: frequency of sampling: 8 or 16 KHz.
  • Returns:

    Builder itself.

@discardableResult
public func setMinVoiceDuration(_ minVoiceDuration: Int64) -> Builder

Sets the minumum voice duration.

  • Parameters:

    • minVoiceDuration: minimum required duration of detected voice (ms).
  • Returns:

    Builder itself.

@discardableResult
public func setMinSnr(_ minSnr: Double) -> Builder

Sets the SNR.

  • Parameters:

    • minSnr: minimum acceptable SNR (signal-to-noise ratio) of the voice.
  • Returns:

    Builder itself.

@discardableResult
public func setRecordingLimit(_ recordingLimit: Int64) -> Builder

Sets the recording limit.

  • Parameters:

    • recordingLimit: maximum duration of recording (ms).
  • Returns:

    Builder itself.

@discardableResult
public func setFormat(_ format: Int) -> Builder

Sets the format.

  • Parameters:

    • format: RAW (double array of samples, normalized in [-1,1]) or WAV (byte array with standard wav format)
  • Returns:

    Builder itself.

@discardableResult
public func setAutoAudioInfo(_ isAutoAudioInfo: Bool) -> Builder

Sets the isAutoAudioInfo parameter.

  • Parameters:

    • isAutoAudioInfo: if true, the audio info will be sent to the listener with each recorded frame.
  • Returns:

    Builder itself.

@discardableResult
public func setAutoVoiceCapture(_ isAutoVoiceCapture: Bool) -> Builder

Sets the isAutoVoiceCapture parameter.

  • Parameters:

    • isAutoVoiceCapture: if true, the whole recorded audio and the trimmed voice will be sent to the listener when the voice duration is enough (according to minVoiceDuration).
  • Returns:

    Builder itself.

@discardableResult
public func setStopOnCapture(_ isStopOnCapture: Bool) -> Builder

Sets the isStopOnCapture parameter.

  • Parameters:

    • isStopOnCapture: if true, the recording stops automatically when the voice is captured.
  • Returns:

    Builder itself.

public func build() -> Config

Builds the configuration builder and creates the voice recorder configuration.

  • Returns:

    Configuration of the voice recorder.