Blame view

egs/aspire/s5/local/multi_condition/get_air_file_patterns.py 2.26 KB
8dcb6dfcb   Yannick Estève   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  #!/usr/bin/env python
  # Copyright 2014  Johns Hopkins University (Authors: Vijayaditya Peddinti).  Apache 2.0.
  
  # script to generate the file_patterns of the AIR database
  # see load_air.m file in AIR db to understand the naming convention
  from __future__ import print_function
  import sys, glob, re, os.path
  
  air_dir = sys.argv[1]
  rir_string = ['binaural' , 'phone']
  phone_pos =  ['hhp', 'hfrp']
  head_pos = [0, 1]
  mockup_types = [1, 2]
  room_string = ['booth' ,  'office' ,  'meeting' ,  'lecture' ,  'stairway' ,  'stairway1' ,  'stairway2' ,  'corridor' ,  'bathroom' ,  'lecture1' ,  'aula_carolina', 'kitchen']
  azimuths = set(range(0, 181, 15))
  azimuths.union(range(0, 181, 45))
  azimuths = list(azimuths)
  azimuths.sort()
  file_patterns = []
  for rir_type in rir_string:
    for room in room_string:
      for head in head_pos:
        for rir_no in range(1, 8):
          for azimuth in azimuths:
            for mockup_type in mockup_types:
              for position in phone_pos:
                if rir_type == 'binaural':
                  if room in set(['stairway', 'stairway1', 'stairway2']):
                    file_pattern = '{0}/air_binaural_{1}_*_{2}_{3}_{4}.mat'.format(air_dir, room, head, rir_no, azimuth)
                  elif room == 'aula_carolina':
                    mic_type = 3
                    file_pattern = '{0}/air_binaural_{1}_*_{2}_{3}_{4}_{5}.mat'.format(air_dir, room, head, rir_no, azimuth, mic_type)
                  else:
                    file_pattern = '{0}/air_binaural_{1}_*_{2}_{3}.mat'.format(air_dir, room, head, rir_no)
                elif rir_type == 'phone':
                  if mockup_type == 1:
                    file_pattern = '{0}/air_phone_{1}_{2}_*.mat'.format(air_dir, room, position)
                  elif mockup_type == 2:
                    file_pattern = '{0}/air_phone_BT_{1}_{2}_*.mat'.format(air_dir, room, position)
                  else:
                    raise Exception('asd')
                files = glob.glob(file_pattern)
                if len(files) > 0:
                  output_file_name = re.sub('mat$', 'wav', re.sub('\_\*', '', file_pattern))
                  output_file_name = os.path.split(output_file_name)[1]
                  file_patterns.append(file_pattern+" "+output_file_name)
  file_patterns = list(set(file_patterns))
  file_patterns.sort()
  print("
  ".join(file_patterns))