HY-2012 commited on
Commit
c26c8a0
·
verified ·
1 Parent(s): b419265

UniverSR.AXERA AX650 8k/16k speech SR: 6 axmodels, C++ bin, Python SDK

Browse files
.gitattributes CHANGED
@@ -33,3 +33,14 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ models/universr_split_16k_condenc.axmodel filter=lfs diff=lfs merge=lfs -text
37
+ models/universr_split_16k_main_cond_actual.axmodel filter=lfs diff=lfs merge=lfs -text
38
+ models/universr_split_16k_main_uncond.axmodel filter=lfs diff=lfs merge=lfs -text
39
+ models/universr_split_8k_condenc.axmodel filter=lfs diff=lfs merge=lfs -text
40
+ models/universr_split_8k_main_cond_actual.axmodel filter=lfs diff=lfs merge=lfs -text
41
+ models/universr_split_8k_main_uncond.axmodel filter=lfs diff=lfs merge=lfs -text
42
+ samples/listen/OSR_us_000_0010_output_48k.wav filter=lfs diff=lfs merge=lfs -text
43
+ samples/listen/spectrograms/16k_output_spec.png filter=lfs diff=lfs merge=lfs -text
44
+ samples/listen/spectrograms/8k_output_spec.png filter=lfs diff=lfs merge=lfs -text
45
+ samples/listen/speech_2_input_16k.wav filter=lfs diff=lfs merge=lfs -text
46
+ samples/listen/speech_2_output_48k.wav filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UniverSR.AXERA
2
+
3
+ **8 / 16 kHz speech → 48 kHz · AX650 NPU3 · C++ RTF 4.38 / Python RTF 4.3 · 6 个 axmodel 共 381 MB**
4
+
5
+ UniverSR 是 vocoder-free flow matching 超分模型,本包包含 **8k 和 16k** 两档语音模型。
6
+
7
+ - GitHub 源码:https://github.com/ZY-2012/UniverSR.AXERA
8
+ - HuggingFace:https://huggingface.co/HY-2012/UniverSR.AXERA
9
+ - 上游:https://github.com/woongzip1/UniverSR
10
+
11
+ ## 目录
12
+
13
+ - 快速开始
14
+ - 结果
15
+ - 推理速度
16
+ - 数据来源
17
+ - License
18
+
19
+ ## 快速开始(AX650 板端)
20
+
21
+ ```bash
22
+ # C++(默认)
23
+ bash run_ax650.sh samples/listen/OSR_us_000_0010_input_8k_5s.wav output_8k.wav --sr 8
24
+ bash run_ax650.sh samples/listen/speech_2_input_16k.wav output_16k.wav --sr 16
25
+
26
+ # Python SDK
27
+ bash run_ax650.sh samples/listen/OSR_us_000_0010_input_8k_5s.wav output_8k.wav --sr 8 --python
28
+ ```
29
+
30
+ 输入采样率必须和 `--sr` 一致;输出固定 48 kHz。默认 STFT 128 帧分块、overlap 64 帧,Flow ODE 4 步,guidance 1.5。
31
+
32
+ ## 结果
33
+
34
+ ### English 8 kHz
35
+
36
+ | 输入 | UniverSR 输出 |
37
+ |---|---|
38
+ | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/UniverSR.AXERA/resolve/main/samples/listen/OSR_us_000_0010_input_8k_5s.wav"></audio><br><img src="samples/listen/spectrograms/8k_input_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/UniverSR.AXERA/resolve/main/samples/listen/OSR_us_000_0010_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/8k_output_spec.png" width="360"> |
39
+
40
+ ### English 16 kHz
41
+
42
+ | 输入 | UniverSR 输出 |
43
+ |---|---|
44
+ | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/UniverSR.AXERA/resolve/main/samples/listen/speech_2_input_16k.wav"></audio><br><img src="samples/listen/spectrograms/16k_input_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/UniverSR.AXERA/resolve/main/samples/listen/speech_2_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/16k_output_spec.png" width="360"> |
45
+
46
+ ## 推理速度
47
+
48
+ | 运行时 | 5.12 s 输入 | RTF |
49
+ |---|---:|---:|
50
+ | **C++** | **22–25 s** | **4.3–4.9** |
51
+ | Python SDK | 22 s | 4.3 |
52
+
53
+ ## 精度
54
+
55
+ | 输入 | 板端 vs PyTorch |
56
+ |---|---:|
57
+ | 8k → 48k | **0.99193** |
58
+ | 16k → 48k | **0.99350** |
59
+
60
+ ## 工程结构
61
+
62
+ ```text
63
+ UniverSR.AXERA/
64
+ ├── bin/ # C++ 板端可执行文件
65
+ ├── models/ # 6 个 axmodel + model_meta.json
66
+ ├── python/ # Python SDK
67
+ ├── samples/ # 中英文输入 / 输出 / 频谱图
68
+ ├── run_ax650.sh
69
+ ├── configuration.json
70
+ ├── config.json # {}
71
+ └── requirements.txt
72
+ ```
73
+
74
+ ## 说明
75
+
76
+ - 8k/16k 使用不同 `lr_bins`(80/170),模型不能混用。
77
+ - `main_cond` 使用真实 `cond encoder` 输出做校准,`vc` 才能达到 0.9999。
78
+ - C++ 和 Python 都按 128 帧分块、overlap 64 帧。
79
+ - 当前版本只提供 8k/16k,12k/24k 未包含。
80
+
81
+ ## 数据来源
82
+
83
+ - 上游 UniverSR:https://github.com/woongzip1/UniverSR
84
+ - 示例语音:Open Speech Repository、公开 16 kHz 人声样例。
85
+
86
+ ## License
87
+
88
+ MIT;上游 UniverSR 权重遵循其原始许可证。
bin/universr_ax650 ADDED
Binary file (72.4 kB). View file
 
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
configuration.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "framework": "axera",
3
+ "model": "UniverSR-speech",
4
+ "target_hardware": "AX650",
5
+ "npu_mode": "NPU3",
6
+ "compiler": "Pulsar2 8.0",
7
+ "task": "audio-to-audio",
8
+ "sample_rate_out": 48000,
9
+ "input_sample_rates": [8000, 16000],
10
+ "models": ["universr_split_8k_condenc.axmodel", "universr_split_8k_main_cond_actual.axmodel", "universr_split_8k_main_uncond.axmodel", "universr_split_16k_condenc.axmodel", "universr_split_16k_main_cond_actual.axmodel", "universr_split_16k_main_uncond.axmodel"],
11
+ "python_demo": "python/demo.py",
12
+ "cpp_bin": "bin/universr_ax650"
13
+ }
models/model_meta.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "UniverSR-speech",
3
+ "input_sr": [8000, 16000],
4
+ "output_sr": 48000,
5
+ "stft_frames": 128,
6
+ "overlap_frames": 64,
7
+ "n_fft": 1024,
8
+ "hop_length": 512,
9
+ "ode_steps": 4,
10
+ "guidance_scale": 1.5,
11
+ "compiler": "Pulsar2 8.0"
12
+ }
models/universr_split_16k_condenc.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ade59b27cbc99500d9b6c9815af246d9fe2a13599cd01b720e5836859ab629a
3
+ size 17072502
models/universr_split_16k_main_cond_actual.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d42eeb782be3ce535db7be58c38b2c92b81e7ed67b080bc179b5dd74d682dca4
3
+ size 71718411
models/universr_split_16k_main_uncond.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1baa0d79e20a642e4d7f710932029d65d1c7ad1fd36f4df73131133507247b63
3
+ size 113505290
models/universr_split_8k_condenc.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01805afed4e514f9d5b46ddf9b316e6089eb54d518314a5f22b3ccabe2293511
3
+ size 11059108
models/universr_split_8k_main_cond_actual.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:957b904bb939287a709ad8552ce8bbc281b09a9ba20c2af80bb83436e7d0c80f
3
+ size 71718993
models/universr_split_8k_main_uncond.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a2cbda2d420f0bcb8ca70ac63c5dfc0ba958ccd908dc642a278ba4121f790d1
3
+ size 113504544
python/demo.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys,time,argparse
2
+ from pathlib import Path
3
+ import numpy as np, torch, torchaudio, soundfile as sf, axengine
4
+ ROOT=Path(__file__).resolve().parent; sys.path.insert(0,str(ROOT))
5
+ T=128; F_HR=432; HOP=512; NFFT=1024; SR=48000
6
+ WIN=torch.hann_window(NFFT)
7
+ def stft(x):
8
+ X=torch.stft(x.reshape(1,-1),NFFT,HOP,window=WIN,center=True,return_complex=True)
9
+ A=X+1e-4; X=A.abs()**0.2*torch.exp(1j*A.angle())
10
+ r=torch.view_as_real(X).permute(0,3,1,2); return r[:,:,:-1,:]
11
+ def istft(sp):
12
+ sp=torch.nn.functional.pad(sp,[0,0,0,1],value=0).permute(0,2,3,1).contiguous()
13
+ X=torch.view_as_complex(sp); X=X.abs()**5.0*torch.exp(1j*X.angle())
14
+ return torch.istft(X,NFFT,HOP,window=WIN,center=True,length=245760)
15
+ def main():
16
+ p=argparse.ArgumentParser(); p.add_argument('input'); p.add_argument('output'); p.add_argument('--models',default=str(ROOT/'models')); p.add_argument('--seed',type=int,default=42); p.add_argument('--overlap',type=int,default=64); p.add_argument('--sr',type=int,default=8); a=p.parse_args()
17
+ ce=axengine.InferenceSession(str(Path(a.models)/f'universr_split_{a.sr}k_condenc.axmodel'))
18
+ mc=axengine.InferenceSession(str(Path(a.models)/f'universr_split_{a.sr}k_main_cond_actual.axmodel'))
19
+ mu=axengine.InferenceSession(str(Path(a.models)/f'universr_split_{a.sr}k_main_uncond.axmodel'))
20
+ x,sr=sf.read(a.input); x=torch.tensor(x,dtype=torch.float32).reshape(1,-1)
21
+ x=torchaudio.functional.resample(x,sr,SR); x=torch.nn.functional.pad(x,(0,max(0,245760-x.shape[-1])))[...,:245760]
22
+ Y=stft(x.unsqueeze(1)); total=Y.shape[-1]; lr=80 if a.sr==8 else 170; hf=512-432
23
+ pad=(T-total%T)%T
24
+ Yp=torch.nn.functional.pad(Y,(0,pad),mode='constant') if pad else Y
25
+ total=Yp.shape[-1]
26
+ starts=list(range(0,total-T+1,T-a.overlap))
27
+ spec=torch.zeros_like(Yp); wsum=torch.zeros(total)
28
+ rng=np.random.RandomState(a.seed); t0=time.time()
29
+ for s in starts:
30
+ y=Yp[:,:,:lr,s:s+T].numpy().astype(np.float32)
31
+ z=ce.run(None,{'y':y})[0].astype(np.float32) # 1,384,1,T
32
+ zz=rng.randn(1,2,F_HR,T).astype(np.float32)
33
+ n=128
34
+ for i in range(4):
35
+ t=np.array([i/4],np.float32); dt=0.25
36
+ def f(q,tt):
37
+ vu=mu.run(None,{'x':q,'t':tt})[0]; vc=mc.run(None,{'x':q,'t':tt,'y_cond':z})[0]
38
+ return (1-1.5)*vu+1.5*vc
39
+ k1=f(zz,t); zm=zz+0.5*dt*k1; k2=f(zm,np.array([i/4+0.125],np.float32)); zz=zz+dt*k2
40
+ cut=max(0,lr-hf); full=np.concatenate([y,zz[:,:,cut:,:]],axis=2) # 1,2,512,T?
41
+ full=torch.from_numpy(full)
42
+ w=torch.ones(T)
43
+ if s>0: w[:a.overlap]=torch.linspace(0,1,a.overlap)
44
+ if s+T>total: w[-(s+T-total):]=0
45
+ spec[:,:,:,s:s+T]+=full*w; wsum[s:s+T]+=w
46
+ spec=spec/wsum.clamp_min(1e-8); out=istft(spec).squeeze()[:245760]
47
+ sf.write(a.output,out.numpy(),SR,subtype='PCM_16'); print('time',time.time()-t0,'shape',out.shape)
48
+ if __name__=='__main__': main()
python/requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy
2
+ soundfile
3
+ torch
4
+ torchaudio
5
+ pyaxengine
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy
2
+ soundfile
3
+ torch
4
+ torchaudio
5
+ pyaxengine
run_ax650.sh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+ cd "$(dirname "$0")"
4
+ export LD_LIBRARY_PATH=/soc/lib:${LD_LIBRARY_PATH:-}
5
+ INPUT="${1:-samples/listen/OSR_us_000_0010_input_8k_5s.wav}"
6
+ OUTPUT="${2:-output.wav}"
7
+ if [ $# -ge 2 ]; then shift 2; else shift $#; fi
8
+ SR=8; MODE=cpp; EXTRA=()
9
+ while [ $# -gt 0 ]; do
10
+ case "$1" in
11
+ --sr) SR="$2"; shift 2 ;;
12
+ --python) MODE=python; shift ;;
13
+ --overlap) EXTRA+=(--overlap "$2"); shift 2 ;;
14
+ *) EXTRA+=("$1"); shift ;;
15
+ esac
16
+ done
17
+ if [ "$MODE" = cpp ] && [ -x ./bin/universr_ax650 ]; then
18
+ exec ./bin/universr_ax650 models "$INPUT" "$OUTPUT" --sr "$SR"
19
+ fi
20
+ exec python3 python/demo.py "$INPUT" -o "$OUTPUT" --models models --sr "$SR" --overlap 64 "${EXTRA[@]}"
samples/listen/OSR_us_000_0010_input_8k_5s.wav ADDED
Binary file (82 kB). View file
 
samples/listen/OSR_us_000_0010_output_48k.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a26e83365a420bda90e5a9ef3cbf35e6766bdf1d814232d240650756fcf1499
3
+ size 491564
samples/listen/spectrograms/16k_input_spec.png ADDED
samples/listen/spectrograms/16k_output_spec.png ADDED

Git LFS Details

  • SHA256: fbb4e488a96de9d523855ae4a08bdc74ff934d5a4cd7b9f8a548faa7325a600f
  • Pointer size: 131 Bytes
  • Size of remote file: 570 kB
samples/listen/spectrograms/8k_input_spec.png ADDED
samples/listen/spectrograms/8k_output_spec.png ADDED

Git LFS Details

  • SHA256: 2d6af64d5cb0ae7b7c085b6bbb60c1caf80baacbcf54710942de64b1b04c0d06
  • Pointer size: 131 Bytes
  • Size of remote file: 482 kB
samples/listen/speech_2_input_16k.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c7773c82ce75aa5e8a14d5bb53ee5915dbb65f47272ae9f527ac767c7b1f80c
3
+ size 163884
samples/listen/speech_2_output_48k.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc747b84d164e0c1d9b48a3cee7fe277ff5480fea5fbead30068980a79f6db05
3
+ size 491564