Skip to content

Commit

Permalink
multiply by 2**32 the audio before PCEN
Browse files Browse the repository at this point in the history
this is in accordance with BV-70k and BV-300k PCEN model
it comes from Richard Lyon's code
  • Loading branch information
Vincent Lostanlen committed Jan 19, 2019
1 parent 479d89a commit 6c2948b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions birdvoxdetect/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def process_file(
# Read audio chunk.
chunk_start = chunk_id * chunk_length
sound_file.seek(chunk_start)
chunk_audio = sound_file.read(chunk_length)
chunk_audio = sound_file.read(chunk_length) * (2**32)

# Compute PCEN.
chunk_pcen = compute_pcen(chunk_audio, sr)
Expand Down Expand Up @@ -210,7 +210,7 @@ def process_file(
# Read chunk.
chunk_start = chunk_id * chunk_length
sound_file.seek(chunk_start)
chunk_audio = sound_file.read(chunk_length)
chunk_audio = sound_file.read(chunk_length) * (2**32)

# Compute PCEN.
deque.popleft()
Expand Down Expand Up @@ -282,7 +282,7 @@ def process_file(
logging.info("Chunk ID: {}/{}".format(n_chunks, n_chunks))
chunk_start = (n_chunks-1) * chunk_length
sound_file.seek(chunk_start)
chunk_audio = sound_file.read(full_length - chunk_start)
chunk_audio = sound_file.read(full_length - chunk_start) * (2**32)
chunk_pcen = compute_pcen(chunk_audio, sr)
if has_context:
# If the queue is empty, compute percentiles on the fly.
Expand Down

0 comments on commit 6c2948b

Please sign in to comment.