Class: Phash::Audio

Inherits:
FileHash show all
Defined in:
lib/phash/audio.rb

Overview

Class to store audio file hash and compare to other

Instance Attribute Summary collapse

Attributes inherited from FileHash

#path

Instance Method Summary collapse

Methods inherited from FileHash

for_paths, hash_type, #phash, #similarity

Constructor Details

#initialize(path, length = nil, sample_rate = nil) ⇒ Audio

Audio path and optional length in seconds to read


121
122
123
# File 'lib/phash/audio.rb', line 121

def initialize(path, length = nil, sample_rate = nil)
  @path, @length, @sample_rate = path, length, sample_rate
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length


118
119
120
# File 'lib/phash/audio.rb', line 118

def length
  @length
end

Instance Method Details

#compute_phashObject


125
126
127
# File 'lib/phash/audio.rb', line 125

def compute_phash
  Phash.audio_hash(@path, @length, @sample_rate)
end