HoneyTian commited on
Commit
349ff6e
·
1 Parent(s): a98e7c4
examples/sample_filter/test1.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import argparse
4
+ from pathlib import Path
5
+ import shutil
6
+
7
+ from gradio_client import Client, handle_file
8
+ from tqdm import tqdm
9
+
10
+
11
+ def get_args():
12
+ parser = argparse.ArgumentParser()
13
+ parser.add_argument(
14
+ "--data_dir",
15
+ default=r"E:\Users\tianx\HuggingDatasets\vm_sound_classification\data\temp\temp",
16
+ type=str
17
+ )
18
+ parser.add_argument(
19
+ "--keep_dir",
20
+ default=r"E:\Users\tianx\HuggingDatasets\vm_sound_classification\data\keep",
21
+ type=str
22
+ )
23
+ parser.add_argument(
24
+ "--trash_dir",
25
+ default=r"E:\Users\tianx\HuggingDatasets\vm_sound_classification\data\trash",
26
+ type=str
27
+ )
28
+ args = parser.parse_args()
29
+ return args
30
+
31
+
32
+ def main():
33
+ args = get_args()
34
+
35
+ data_dir = Path(args.data_dir)
36
+ keep_dir = Path(args.keep_dir)
37
+ keep_dir.mkdir(parents=True, exist_ok=True)
38
+ trash_dir = Path(args.trash_dir)
39
+ trash_dir.mkdir(parents=True, exist_ok=True)
40
+
41
+ client = Client("http://127.0.0.1:7864/")
42
+
43
+ for filename in tqdm(data_dir.glob("*.wav")):
44
+ filename = filename.as_posix()
45
+
46
+ label, prob = client.predict(
47
+ audio=handle_file(filename),
48
+ model_name="vm_sound_classification8-ch32",
49
+ ground_true="Hello!!",
50
+ api_name="/click_button"
51
+ )
52
+ prob = float(prob)
53
+
54
+ if prob > 0.7:
55
+ shutil.move(
56
+ filename,
57
+ trash_dir.as_posix(),
58
+ )
59
+ else:
60
+ shutil.move(
61
+ filename,
62
+ keep_dir.as_posix(),
63
+ )
64
+
65
+ return
66
+
67
+
68
+ if __name__ == '__main__':
69
+ main()
examples/vm_sound_classification/run.sh CHANGED
@@ -15,7 +15,9 @@ E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/id-ID/w
15
  sh run.sh --stage 0 --stop_stage 5 --system_version centos --file_folder_name file_dir --final_model_name vm_sound_classification8-ch32 \
16
  --filename_patterns "/data/tianxing/PycharmProjects/datasets/voicemail/*/wav_finished/*/*.wav" --label_plan 8
17
 
18
- "
 
 
19
 
20
  END
21
 
 
15
  sh run.sh --stage 0 --stop_stage 5 --system_version centos --file_folder_name file_dir --final_model_name vm_sound_classification8-ch32 \
16
  --filename_patterns "/data/tianxing/PycharmProjects/datasets/voicemail/*/wav_finished/*/*.wav" --label_plan 8
17
 
18
+ sh run.sh --stage 0 --stop_stage 5 --system_version centos --file_folder_name file_dir --final_model_name vm_sound_classification2-ch32-voicemail \
19
+ --filename_patterns "/data/tianxing/PycharmProjects/datasets/voicemail/th-TH/wav_finished/*/*.wav" --label_plan 2-voicemail
20
+
21
 
22
  END
23
 
examples/vm_sound_classification/step_1_prepare_data.py CHANGED
@@ -39,7 +39,20 @@ def get_dataset(args):
39
  file_dir = Path(args.file_dir)
40
  file_dir.mkdir(exist_ok=True)
41
 
42
- if args.label_plan == "2":
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  label_map = {
44
  "bell": "non_voice",
45
  "white_noise": "non_voice",
 
39
  file_dir = Path(args.file_dir)
40
  file_dir.mkdir(exist_ok=True)
41
 
42
+ if args.label_plan == "2-voicemail":
43
+ label_map = {
44
+ "bell": "voicemail",
45
+ "white_noise": "non_voicemail",
46
+ "low_white_noise": "non_voicemail",
47
+ "high_white_noise": "non_voicemail",
48
+ # "music": "non_voicemail",
49
+ "mute": "non_voicemail",
50
+ "noise": "non_voicemail",
51
+ "noise_mute": "non_voicemail",
52
+ "voice": "non_voicemail",
53
+ "voicemail": "voicemail",
54
+ }
55
+ elif args.label_plan == "2":
56
  label_map = {
57
  "bell": "non_voice",
58
  "white_noise": "non_voice",