MLSpeech commited on
Commit
42055ce
·
verified ·
1 Parent(s): 4164e22

Fixed filename string search bug

Browse files

Change substring match to exact string match when searching for audio files listed in the input map file.

Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -129,8 +129,10 @@ def grMeasureDistance(wav_paths, map_file):
129
  wav_pairs = []
130
 
131
  for index, row in map_df.iterrows():
132
- file1_index = find_substring_index(names, row['S1'])
133
- file2_index = find_substring_index(names, row['S2'])
 
 
134
 
135
  if(file1_index != -1 and file2_index != -1):
136
  wav_pairs.append((names[file1_index], names[file2_index]))
@@ -152,6 +154,12 @@ def find_substring_index(string_list, substring):
152
  return index
153
  return -1
154
 
 
 
 
 
 
 
155
  #csv export function
156
  def export_csv(d):
157
  if(len(d.iloc[0,0])>0):
 
129
  wav_pairs = []
130
 
131
  for index, row in map_df.iterrows():
132
+ #file1_index = find_substring_index(names, row['S1'])
133
+ #file2_index = find_substring_index(names, row['S2'])
134
+ file1_index = find_exactstring_index(names, row['S1'])
135
+ file2_index = find_exactstring_index(names, row['S2'])
136
 
137
  if(file1_index != -1 and file2_index != -1):
138
  wav_pairs.append((names[file1_index], names[file2_index]))
 
154
  return index
155
  return -1
156
 
157
+ def find_exactstring_index(string_list, substring):
158
+ for index, string in enumerate(string_list):
159
+ if substring == os.path.basename(string):
160
+ return index
161
+ return -1
162
+
163
  #csv export function
164
  def export_csv(d):
165
  if(len(d.iloc[0,0])>0):