HoneyTian commited on
Commit
340eeda
1 Parent(s): 07bfb6f
Dockerfile CHANGED
@@ -11,6 +11,8 @@ RUN pip install --upgrade pip
11
 
12
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
13
 
 
 
14
  # Set up a new user named "user" with user ID 1000
15
  RUN useradd -m -u 1000 user
16
 
 
11
 
12
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
13
 
14
+ RUN export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.8/site-packages/k2/lib/
15
+
16
  # Set up a new user named "user" with user ID 1000
17
  RUN useradd -m -u 1000 user
18
 
README.md CHANGED
@@ -42,6 +42,17 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/miniconda3/envs/ASR/lib/
42
 
43
  https://blog.csdn.net/qq_38225558/article/details/128641561
44
  ```text
45
- ImportError: /lib64/libm.so.6: version `GLIBC_2.27' not found
 
 
 
 
 
 
46
  ```
47
 
 
 
 
 
 
 
42
 
43
  https://blog.csdn.net/qq_38225558/article/details/128641561
44
  ```text
45
+ ImportError: libk2_torch_api.so: cannot open shared object file: No such file or directory
46
+
47
+ ```
48
+
49
+ 查找 libk2_torch_api.so 共享库所在目录
50
+ ```text
51
+ find / -name libk2_torch_api.so
52
  ```
53
 
54
+ 添加 LD_LIBRARY_PATH
55
+ ```text
56
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.8/site-packages/k2/lib/
57
+
58
+ ```
examples/wenet/{test.py → downaload_model.py} RENAMED
@@ -9,7 +9,6 @@ pwd = os.path.abspath(os.path.dirname(__file__))
9
  sys.path.append(os.path.join(pwd, "../../"))
10
 
11
  import huggingface_hub
12
- import sherpa
13
 
14
  from project_settings import project_path
15
 
@@ -61,23 +60,6 @@ def main():
61
  local_dir=model_dir.as_posix(),
62
  )
63
  print(tokens_filename)
64
-
65
- feat_config = sherpa.FeatureConfig(normalize_samples=False)
66
- feat_config.fbank_opts.frame_opts.samp_freq = 16000
67
- feat_config.fbank_opts.mel_opts.num_bins = 80
68
- feat_config.fbank_opts.frame_opts.dither = 0
69
-
70
- config = sherpa.OfflineRecognizerConfig(
71
- nn_model=model_filename,
72
- tokens=tokens_filename,
73
- use_gpu=False,
74
- feat_config=feat_config,
75
- decoding_method="greedy_search",
76
- num_active_paths=2,
77
- )
78
-
79
- recognizer = sherpa.OfflineRecognizer(config)
80
- print(recognizer)
81
  return
82
 
83
 
 
9
  sys.path.append(os.path.join(pwd, "../../"))
10
 
11
  import huggingface_hub
 
12
 
13
  from project_settings import project_path
14
 
 
60
  local_dir=model_dir.as_posix(),
61
  )
62
  print(tokens_filename)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  return
64
 
65
 
examples/wenet/infer.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import argparse
4
+ import os
5
+ from pathlib import Path
6
+ import sys
7
+
8
+ pwd = os.path.abspath(os.path.dirname(__file__))
9
+ sys.path.append(os.path.join(pwd, "../../"))
10
+
11
+ import sherpa
12
+
13
+ from project_settings import project_path
14
+
15
+
16
+ def get_args():
17
+ parser = argparse.ArgumentParser()
18
+ parser.add_argument(
19
+ "--model_dir",
20
+ default=(project_path / "pretrained_models/huggingface/csukuangfj/wenet-chinese-model").as_posix(),
21
+ type=str
22
+ )
23
+ args = parser.parse_args()
24
+ return args
25
+
26
+
27
+ def main():
28
+ args = get_args()
29
+
30
+ model_dir = Path(args.model_dir)
31
+ model_filename = model_dir / "final.zip"
32
+ tokens_filename = model_dir / "units.txt"
33
+
34
+ feat_config = sherpa.FeatureConfig(normalize_samples=False)
35
+ feat_config.fbank_opts.frame_opts.samp_freq = 16000
36
+ feat_config.fbank_opts.mel_opts.num_bins = 80
37
+ feat_config.fbank_opts.frame_opts.dither = 0
38
+
39
+ config = sherpa.OfflineRecognizerConfig(
40
+ nn_model=model_filename.as_posix(),
41
+ tokens=tokens_filename.as_posix(),
42
+ use_gpu=False,
43
+ feat_config=feat_config,
44
+ decoding_method="greedy_search",
45
+ num_active_paths=2,
46
+ )
47
+
48
+ recognizer = sherpa.OfflineRecognizer(config)
49
+ print(recognizer)
50
+ return
51
+
52
+
53
+ if __name__ == "__main__":
54
+ main()