Blame view

egs/voxforge/s5/local/voxforge_map_anonymous.sh 887 Bytes
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
  #!/bin/bash
  
  # Copyright 2012 Vassil Panayotov
  # Apache 2.0
  
  # Map anonymous users to unique IDs
  
  echo "=== Starting to map anonymous users to unique IDs ..."
  
  if [ $# -ne 1 ]; then
    echo "Usage: $0 <data-dir>"
    exit 1
  fi
  
  data=$1
  data_local=data/local
  
  if [ ! -d $data ]; then
    echo "\"$DATA\" is not a directory!"
    exit 1
  fi
  
  mkdir -p $data_local
  
  echo "--- Mapping the \"anonymous\" speakers to unique IDs ..."
  ls -d $data/anonymous-*-* |\
   awk '
   BEGIN {i=0}
   { anon_users[++i] = $0; }
   END { for (j in anon_users) {printf("anonymous%04d %s
  ", j, anon_users[j]);}}' |\
   sort -k1 > $data_local/anon.map
  
  while read l; do
    user=$(echo $l | cut -f1 -d' ')
    echo "$l" | cut -f2- -d' ' | while read -r ad; do
      newdir=`echo "$ad" | sed -e 's:anonymous\(-.*-.*\):'$user'\1:'`
      mv $ad $newdir
    done
  done < "${data_local}/anon.map"
  
  echo "*** Finished mapping anonymous users!"