Skip to content

Commit

Permalink
Optimize panda use on steinburg to fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean1572 committed Jun 28, 2022
1 parent eeea93c commit 5f00a09
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
14 changes: 2 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,5 @@ PyHa/tweetynet_package/tweetynet/__pycache__/Load_data_functions.cpython-37.pyc
PyHa/tweetynet_package/tweetynet/__pycache__/network.cpython-37.pyc
PyHa/tweetynet_package/tweetynet/__pycache__/TweetyNetAudio.cpython-37.pyc
PyHa/tweetynet_package/tweetynet/__pycache__/TweetyNetModel.cpython-37.pyc
TEST/ScreamingPiha1.wav
TEST/ScreamingPiha10.wav
TEST/ScreamingPiha11.wav
TEST/ScreamingPiha2.wav
TEST/ScreamingPiha3.wav
TEST/ScreamingPiha4.wav
TEST/ScreamingPiha5.wav
TEST/ScreamingPiha6.wav
TEST/ScreamingPiha7.wav
TEST/ScreamingPiha8.wav
TEST/ScreamingPiha9.wav
*.wav
*.wav
*.pyc
27 changes: 20 additions & 7 deletions PyHa/IsoAutio.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,28 @@ def steinberg_isolate(
# as a potential optimization problem
# rework the algorithm so that it builds the dataframe correctly to save
# time.

OFFSET = entry['OFFSET'].str[0]
DURATION = entry['OFFSET'].str[1]
DURATION = DURATION - OFFSET
entry.assign(
OFFSET=entry['OFFSET'].apply(get_offset),
DURATION=entry['OFFSET'].apply(get_duration)
)

#OFFSET = entry['OFFSET'].str[0] #OFFSET = entry['OFFSET'].str[0]
#DURATION = entry['OFFSET'].str[1] #DURATION = entry['OFFSET'].str[1]
#DURATION = DURATION - OFFSET
# Adding a new "DURATION" Column
# Making compatible with Kaleidoscope
entry.insert(6, "DURATION", DURATION)
entry["OFFSET"] = OFFSET
#entry.insert(6, "DURATION", DURATION)
#entry["OFFSET"] = OFFSET
return entry

## STEINBURG HELPER FUNCTIONS
def get_offset(arr):
return arr[0]

def get_duration(arr):
return arr[1] - arr[0]



def simple_isolate(
local_scores,
Expand Down Expand Up @@ -969,8 +981,9 @@ def generate_automated_labels_tweetynet(
annotations = new_entry
else:
annotations = annotations.append(new_entry)
except BaseException:
except BaseException as e:
print("Error in isolating bird calls from", audio_file)
print(e)
continue
# Quick fix to indexing
annotations.reset_index(inplace=True, drop=True)
Expand Down

0 comments on commit 5f00a09

Please sign in to comment.