HoneyTian commited on
Commit
e8560e7
·
1 Parent(s): b0db8c1
Files changed (2) hide show
  1. main.py +7 -4
  2. silero/main.go +5 -2
main.py CHANGED
@@ -6,6 +6,7 @@ import json
6
  from pathlib import Path
7
  import platform
8
  import re
 
9
 
10
  from project_settings import project_path, log_directory
11
  import log
@@ -30,15 +31,17 @@ def get_args():
30
  args = parser.parse_args()
31
  return args
32
 
33
- def process_uploaded_file(vad_engine: str, filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> str:
 
34
  if vad_engine == "nx_vad":
35
  return run_nx_vad(filename, silence_time, longest_activate)
36
  elif vad_engine == "silero-vad":
37
  return run_silero_vad(filename, silence_time, longest_activate)
38
  else:
39
- return f"vad engine invalid: {vad_engine}"
 
40
 
41
- def run_nx_vad(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> str:
42
  filename = Path(filename).as_posix()
43
 
44
  main_logger.info("do nx vad: {}".format(filename))
@@ -58,7 +61,7 @@ def run_nx_vad(filename: str, silence_time: float = 0.3, longest_activate: float
58
  return raw_vad_result, vad_timestamps
59
 
60
 
61
- def run_silero_vad(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> str:
62
  filename = Path(filename).as_posix()
63
 
64
  main_logger.info("do silero vad: {}".format(filename))
 
6
  from pathlib import Path
7
  import platform
8
  import re
9
+ from typing import Tuple
10
 
11
  from project_settings import project_path, log_directory
12
  import log
 
31
  args = parser.parse_args()
32
  return args
33
 
34
+
35
+ def process_uploaded_file(vad_engine: str, filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> Tuple[str, str]:
36
  if vad_engine == "nx_vad":
37
  return run_nx_vad(filename, silence_time, longest_activate)
38
  elif vad_engine == "silero-vad":
39
  return run_silero_vad(filename, silence_time, longest_activate)
40
  else:
41
+ return f"vad engine invalid: {vad_engine}", ""
42
+
43
 
44
+ def run_nx_vad(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> Tuple[str, str]:
45
  filename = Path(filename).as_posix()
46
 
47
  main_logger.info("do nx vad: {}".format(filename))
 
61
  return raw_vad_result, vad_timestamps
62
 
63
 
64
+ def run_silero_vad(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> Tuple[str, str]:
65
  filename = Path(filename).as_posix()
66
 
67
  main_logger.info("do silero vad: {}".format(filename))
silero/main.go CHANGED
@@ -50,9 +50,12 @@ func main() {
50
  }
51
 
52
  for _, s := range segments {
53
- log.Printf("speech starts at %0.2fs", s.SpeechStartAt)
 
 
54
  if s.SpeechEndAt > 0 {
55
- log.Printf("speech ends at %0.2fs", s.SpeechEndAt)
 
56
  }
57
  }
58
 
 
50
  }
51
 
52
  for _, s := range segments {
53
+ // log.Printf("speech starts at %0.2fs", s.SpeechStartAt)
54
+ fmt.Println("speech starts at %0.2fs", s.SpeechStartAt)
55
+
56
  if s.SpeechEndAt > 0 {
57
+ // log.Printf("speech ends at %0.2fs", s.SpeechEndAt)
58
+ fmt.Println("speech ends at %0.2fs", s.SpeechEndAt)
59
  }
60
  }
61