Skip to content

Commit 14fd746

Browse files
committed
do not trim off recording file extension when naming generated files
1 parent 0d11e4c commit 14fd746

27 files changed

Lines changed: 210 additions & 243 deletions

app/post-process.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
import sys
24
import ast
35
import os
@@ -25,9 +27,7 @@
2527

2628
M.init(None, os.path.join(__dir__, "configuration.py"), False)
2729

28-
wavfile_noext = M.trim_ext(wavfile)
29-
30-
with open(wavfile_noext+"-classify.log",'r') as fid:
30+
with open(wavfile+"-classify.log",'r') as fid:
3131
for line in fid:
3232
if "labels: " in line:
3333
m=re.search('labels: (.+)',line)
@@ -40,13 +40,13 @@
4040

4141
if delete_wavs:
4242
for label in labels:
43-
fullpath = wavfile_noext+'-'+label+'.wav'
43+
fullpath = wavfile+'-'+label+'.wav'
4444
os.remove(fullpath)
4545
print("deleting ", fullpath)
4646

4747
durations = {}
4848
counts = {}
49-
with open(wavfile_noext+'-predicted-1.0pr.csv') as fid:
49+
with open(wavfile+'-predicted-1.0pr.csv') as fid:
5050
csvreader = csv.reader(fid)
5151
for row in csvreader:
5252
if row[4] not in durations:
@@ -55,7 +55,7 @@
5555
durations[row[4]] += (int(row[2]) - int(row[1]))
5656
counts[row[4]] += 1
5757

58-
with open(wavfile_noext+"-post-process.csv",'w') as fid:
58+
with open(wavfile+"-post-process.csv",'w') as fid:
5959
fid.write("wavfile,label,duration ("+M.context_time_units+"),num events\n")
6060
for label in durations.keys():
6161
fid.write(os.path.basename(wavfile)+','+
@@ -64,8 +64,8 @@
6464
str(counts[label])+'\n')
6565

6666
if delete_logs:
67-
os.remove(wavfile_noext+'-classify.log')
68-
os.remove(wavfile_noext+'-ethogram.log')
69-
os.remove(wavfile_noext+'-post-process.log')
67+
os.remove(wavfile+'-classify.log')
68+
os.remove(wavfile+'-ethogram.log')
69+
os.remove(wavfile+'-post-process.log')
7070

7171
print(str(datetime.now())+": finish time")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/classify

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def main():
8484

8585
load_audio_read_plugin(FLAGS.audio_read_plugin, FLAGS.audio_read_plugin_kwargs)
8686
load_video_read_plugin(FLAGS.video_read_plugin, FLAGS.video_read_plugin_kwargs)
87-
from lib import audio_read, video_read, trim_ext
87+
from lib import audio_read, video_read
8888

8989
with open(FLAGS.model_labels, 'r') as fid:
9090
model_labels = fid.read().splitlines()
@@ -255,13 +255,11 @@ def main():
255255
else:
256256
adjusted_probability = probability_matrix[:,ch]
257257
waveform = adjusted_probability*np.iinfo(np.int16).max
258-
withoutext = trim_ext(FLAGS.wav)
259-
filename = withoutext+'-'+labels[ch]+'.wav'
258+
filename = FLAGS.wav+'-'+labels[ch]+'.wav'
260259
wavfile.write(filename, int(sample_rate), waveform.astype('int16'))
261260
else:
262261
waveform = probability_matrix * np.iinfo(np.int16).max
263-
withoutext = trim_ext(FLAGS.wav)
264-
filename = withoutext+'-.wav'
262+
filename = FLAGS.wav+'-.wav'
265263
wavfile.write(filename, int(sample_rate), waveform.astype('int16'))
266264

267265
if __name__ == '__main__':

0 commit comments

Comments
 (0)