zohann commited on
Commit
821547c
·
verified ·
1 Parent(s): c340eff

Upload Audio_Effects_SDK/samples/effects_delayed_streams_demo/run_effect_chained.sh with huggingface_hub

Browse files
Audio_Effects_SDK/samples/effects_delayed_streams_demo/run_effect_chained.sh ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Config file location
4
+ cfg_file=/tmp/tmp_cfg.txt
5
+
6
+ effect1="denoiser"
7
+ effect2="superres"
8
+ gpu="t4"
9
+ ulimit_val=0
10
+ sample_rate1=16
11
+ sample_rate2=16
12
+ output_sample_rate1=16
13
+ output_sample_rate2=48
14
+ batch_size=10
15
+ reset=
16
+ multi_input=""
17
+ frame_size=10;
18
+ enable_vad=
19
+ ALL_STREAMS_ACTIVE="one_step_delay_streams none
20
+ two_step_delay_streams none"
21
+ SOME_STREAMS_ACTIVE="one_step_delay_streams 0 2 6 8
22
+ two_step_delay_streams 3 5 9"
23
+
24
+ active_streams=$SOME_STREAMS_ACTIVE
25
+
26
+ declare -A gpu_map=( ["a100"]="sm_80"
27
+ ["a30"]="sm_80"
28
+ ["a2"]="sm_86"
29
+ ["a10"]="sm_86"
30
+ ["a16"]="sm_86"
31
+ ["a40"]="sm_86"
32
+ ["t4"]="sm_75"
33
+ ["v100"]="sm_70"
34
+ )
35
+ declare -a supported_effects=( "denoiser_16k_superres_16k"
36
+ "dereverb_16k_superres_16k"
37
+ "dereverb_denoiser_16k_superres_16k"
38
+ "superres_8k_denoiser_16k"
39
+ "superres_8k_dereverb_16k"
40
+ "superres_8k_dereverb_denoiser_16k"
41
+ "superres_8k_dereverb_denoiser_16k"
42
+ )
43
+
44
+ gpu_list=$(IFS=/; printf "%s" "${!gpu_map[*]}")
45
+
46
+ while [[ "$#" -gt 0 ]]; do
47
+ case $1 in
48
+ -e1|--effect1) effect1="$2"; shift ;;
49
+ -e2|--effect2) effect2="$2"; shift ;;
50
+ -g|--gpu) gpu="$2"; shift ;;
51
+ -u|--ulimit) ulimit_val="$2"; shift ;;
52
+ -s1|--sample_rate) sample_rate1="$2"; shift ;;
53
+ -s2|--sample_rate2) sample_rate2="$2"; shift ;;
54
+ -o1|--output_sample_rate1) output_sample_rate1="$2"; shift ;;
55
+ -o2|--output_sample_rate2) output_sample_rate2="$2"; shift ;;
56
+ -c|--cfg-file) cfg_file="$2"; shift;;
57
+ -r|--reset) multi_input="0,1,2,3,4" reset="reset 2 3 5";;
58
+ -f|--frame_size) frame_size="$2"; shift;;
59
+ -v|--enable_vad) enable_vad=1;;
60
+ -t|--all_streams_active) all_streams_active=$ALL_STREAMS_ACTIVE;;
61
+ -h|--help) echo -e "-g, --gpu : $gpu_list [default=t4]"
62
+ echo -e "-e1, --effect1 : First effect to use: denoiser/dereverb/dereverb_denoiser/aec/superres [default=denoiser]"
63
+ echo -e "-e2, --effect2 : Second effect to use: denoiser/dereverb/dereverb_denoiser/aec/superres [default=denoiser]"
64
+ echo -e "-u, --ulimit : raise files open ulimit, this is used when running larger batch sizes that exceed the kernel maximum open files limit. Warning: Use this option with caution. [default=0(unusued)]"
65
+ echo -e "-s1, --sample_rate1 : sample rate to use 8/16/48 (in kHz) for first effect. [default=16]"
66
+ echo -e "-s2, --sample_rate2 : sample rate to use 8/16/48 (in kHz) for second effect. [default=48]"
67
+ echo -e "-o1, --output_sample_rate1 : output sample rate to use 16/48 (in kHz) for first effect. [default=48]"
68
+ echo -e "-o2, --output_sample_rate2 : output sample rate to use 16/48 (in kHz) for second effect. [default=48]"
69
+ echo -e "-c, --cfg-file: configuration file to write to"
70
+ echo -e "-f, --frame_size: frame size to be used 10/20ms. [default=10]"
71
+ echo -e "-v, --enable_vad: Enable VAD. Refer to the Programming Guide for supported effects. [default=disabled]"
72
+ echo -e "-t, --all_streams_active: Make all streams active (streams are delayed by default)"
73
+ echo -e "-h, --help: print this help menu";exit;;
74
+ *) echo "Unknown parameter passed: $1"; exit 1 ;;
75
+ esac
76
+ shift
77
+ done
78
+
79
+ effect_check="\b${effect1}_${sample_rate1}k_${effect2}_${sample_rate2}k\b"
80
+ if ! [[ "${supported_effects[@]}" =~ ${effect_check} ]]; then
81
+ echo "Chain (${effect1} ${sample_rate1}k + ${effect2} ${sample_rate2}k) is not supported. Supported chains are:"
82
+ for e in "${supported_effects[@]}"; do
83
+ v=${e//k_/k + }
84
+ echo "- ${v//_/ }"
85
+ done
86
+ exit 1
87
+ fi
88
+ input_list=""
89
+ folder="${effect1}_${sample_rate1}k_${effect2}_${sample_rate2}k"
90
+ wav=$(./list.sh ../input_files/chaining/${folder}/ ${batch_size} ${multi_input})
91
+ if [ $? -ne 0 ]; then
92
+ echo "Error generating input files list"
93
+ echo "Command returned: $wav"
94
+ exit 1
95
+ fi
96
+ input_list="input_wav_list $wav"
97
+
98
+ out_file=""
99
+ for i in $(seq 1 $batch_size); do
100
+ out_file="$out_file ${effect1}${sample_rate1}k_${effect2}${sample_rate2}k_$i.wav"
101
+ done
102
+
103
+ if [ -z "${gpu_map[$gpu]:-}" ]; then
104
+ echo "Invalid GPU (got $gpu, supported $gpu_list)"
105
+ exit 1
106
+ fi
107
+ arch="${gpu_map[$gpu]}"
108
+
109
+ model1="../../models"
110
+ model2="../../models"
111
+ if [ "$effect1" == "superres" ]; then
112
+ model1="${model1}/${arch}/${effect1}_${sample_rate1}k_to_${output_sample_rate1}k.trtpkg"
113
+ else
114
+ model1="${model1}/${arch}/${effect1}_${sample_rate1}k.trtpkg"
115
+ fi
116
+
117
+ if [ "$effect2" == "superres" ]; then
118
+ model2="${model2}/${arch}/${effect2}_${sample_rate2}k_to_${output_sample_rate2}k.trtpkg"
119
+ else
120
+ model2="${model2}/${arch}/${effect2}_${sample_rate2}k.trtpkg"
121
+ fi
122
+
123
+ echo "effect ${effect1} ${effect2}
124
+ sample_rate ${sample_rate1}000 ${sample_rate2}000
125
+ model ${model1} ${model2}
126
+ real_time 0
127
+ $active_streams
128
+ $input_list
129
+ output_wav_list $out_file
130
+ frame_size ${frame_size}" > $cfg_file
131
+
132
+ if [ ! -z "$reset" ]; then
133
+ echo "$reset" >> $cfg_file
134
+ fi
135
+
136
+ if [ ! -z "$enable_vad" ]; then
137
+ echo "enable_vad 1" >> $cfg_file
138
+ fi
139
+
140
+ echo "Using the config file $cfg_file"
141
+
142
+ if [ "$ulimit_val" -ne "0" ]; then
143
+ if [ "$ulimit_val" -le "1024" ]; then
144
+ echo "You probably dont want to do this. ulimit is too low.";
145
+ exit;
146
+ fi
147
+ echo "ulimit set to ${ulimit_val}";
148
+ ulimit -n $ulimit_val
149
+ exit;
150
+ fi
151
+
152
+ ./effects_delayed_streams_demo -c $cfg_file