Skip to content

VoiceRecorder.Config

Class for configuring the VoiceRecorder. Please use Config.Builder to create a new instance.

Properties

public static let RAW_FORMAT = 1

Constant with the value of raw format.

public static let WAV_FORMAT = 2

Constant with the value of wav format.

public let frameLength: Int

Number of samples.

public let fs: Int

Frequency of sampling: 8 or 16 KHz.

public let minVoiceDuration: Int64

The minimum required duration of detected voice (ms).

public let minSnr: Double

The minimum acceptable SNR (signal-to-noise ratio) of the voice.

private(set) var recordingLimit: Int64

The maximum duration of recording (ms)

private(set) var format: Int

Format of the recording. RAW (double array of samples, normalized in [-1,1]), WAV (byte array with standard wav format), WAV in base64

private(set) var isAutoAudioInfo: Bool

If true, the audio info will be sent to the listener with each recorded frame.

private(set) var isAutoVoiceCapture: Bool

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).

private(set) var isStopOnCapture: Bool

If true, the recording stops automatically when the voice is captured.

public var minVoiceLength: Int64

Minimum required duration of detected voice (ms).

Public Methods

public init(
 _ fs: Int,
 _ minVoiceDuration: Int64,
 _ minSnr: Double,
 _ recordingLimit: Int64,
 _ format: Int,
 _ isAutoAudioInfo: Bool,
 _ isAutoVoiceCapture: Bool,
 _ isStopOnCapture: Bool
)

Constructor of the class.

  • Parameters:

    • fs: frequency of sampling: 8 or 16 KHz.
    • minVoiceDuration: the minimum required duration of detected voice (ms).
    • minSnr: the minimum acceptable SNR (signal-to-noise ratio) of the voice.
    • recordingLimit: maximum duration of recording (ms).
    • format: RAW (double array of samples, normalized in [-1,1]) or WAV (byte array with standard wav format)
    • isAutoAudioInfo: if true, the audio info will be sent to the listener with each recorded frame.
    • 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).
    • isStopOnCapture: if true, the recording stops automatically when the voice is captured.
public convenience init(_ config: VoiceRecorder.Config)

Convenience constructor of the class.

  • Parameters:

    • config: configuration of the voice recorder.
public func setRecordingLimit(_ recordingLimit: Int64)

Sets the recording limit.

  • Parameters:

    • recordingLimit: maximum duration of recording (ms).
public func setFormat(_ format: Int)

Sets the format.

- Parameters:

  - **format**: RAW (double array of samples, normalized in [-1,1]) or WAV (byte array with standard wav format)
public func setAutoAudioInfo(_ isAutoAudioInfo: Bool)

Sets the isAutoAudioInfo parameter.

  • Parameters:

    • isAutoAudioInfo: if true, the audio info will be sent to the listener with each recorded frame.
public func setAutoVoiceCapture(_ isAutoVoiceCapture: Bool)

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).
public func setStopOnCapture(_ isStopOnCapture: Bool)

Sets the isStopOnCapture parameter.

  • Parameters:

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