FlowHigh AX650 U16/S8 quantized models, Python runtime and samples
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +54 -0
- LICENSE +21 -0
- README.md +145 -0
- assets/time_emb_4.npy +3 -0
- config.json +1 -0
- models/bigvgan.axmodel +3 -0
- models/flowhigh.axmodel +3 -0
- python/demo_board.py +107 -0
- python/flowhigh_sdk/__init__.py +0 -0
- python/flowhigh_sdk/audio.py +138 -0
- python/requirements.txt +3 -0
- reports/quantization.md +67 -0
- run_ax650.sh +8 -0
- samples/listen/16k/speech_2_input_16k.wav +3 -0
- samples/listen/16k/speech_3_input_16k.wav +3 -0
- samples/listen/48k_from16k/speech_2_output_48k.wav +3 -0
- samples/listen/48k_from16k/speech_3_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_cn_000_0072_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_cn_000_0073_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_cn_000_0074_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_cn_000_0075_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_us_000_0010_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_us_000_0013_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_us_000_0057_output_48k.wav +3 -0
- samples/listen/48k_from8k/OSR_us_000_0059_output_48k.wav +3 -0
- samples/listen/48k_from8k/samplelib_speech_1m_output_48k.wav +3 -0
- samples/listen/48k_from8k/speech_2_output_48k.wav +3 -0
- samples/listen/48k_from8k/speech_3_output_48k.wav +3 -0
- samples/listen/8k/OSR_cn_000_0072_input_8k.wav +3 -0
- samples/listen/8k/OSR_cn_000_0073_input_8k.wav +3 -0
- samples/listen/8k/OSR_cn_000_0074_input_8k.wav +3 -0
- samples/listen/8k/OSR_cn_000_0075_input_8k.wav +3 -0
- samples/listen/8k/OSR_us_000_0010_input_8k.wav +3 -0
- samples/listen/8k/OSR_us_000_0013_input_8k.wav +3 -0
- samples/listen/8k/OSR_us_000_0057_input_8k.wav +3 -0
- samples/listen/8k/OSR_us_000_0059_input_8k.wav +3 -0
- samples/listen/8k/samplelib_speech_1m_input_8k.wav +3 -0
- samples/listen/8k/speech_2_input_8k.wav +0 -0
- samples/listen/8k/speech_3_input_8k.wav +0 -0
- samples/listen/spectrograms/OSR_cn_000_0072_input_8k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0072_output_48k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0073_input_8k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0073_output_48k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0074_input_8k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0074_output_48k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0075_input_8k_spec.png +3 -0
- samples/listen/spectrograms/OSR_cn_000_0075_output_48k_spec.png +3 -0
- samples/listen/spectrograms/OSR_us_000_0010_input_8k_spec.png +3 -0
- samples/listen/spectrograms/OSR_us_000_0010_output_48k_spec.png +3 -0
- samples/listen/spectrograms/OSR_us_000_0013_input_8k_spec.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,57 @@ 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/bigvgan.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
models/flowhigh.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
samples/listen/16k/speech_2_input_16k.wav filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
samples/listen/16k/speech_3_input_16k.wav filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
samples/listen/48k_from16k/speech_2_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
samples/listen/48k_from16k/speech_3_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
samples/listen/48k_from8k/OSR_cn_000_0072_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
samples/listen/48k_from8k/OSR_cn_000_0073_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
samples/listen/48k_from8k/OSR_cn_000_0074_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
samples/listen/48k_from8k/OSR_cn_000_0075_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
samples/listen/48k_from8k/OSR_us_000_0010_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
samples/listen/48k_from8k/OSR_us_000_0013_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
samples/listen/48k_from8k/OSR_us_000_0057_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
samples/listen/48k_from8k/OSR_us_000_0059_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
samples/listen/48k_from8k/samplelib_speech_1m_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
samples/listen/48k_from8k/speech_2_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
samples/listen/48k_from8k/speech_3_output_48k.wav filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
samples/listen/8k/OSR_cn_000_0072_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
samples/listen/8k/OSR_cn_000_0073_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
samples/listen/8k/OSR_cn_000_0074_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
samples/listen/8k/OSR_cn_000_0075_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
samples/listen/8k/OSR_us_000_0010_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
samples/listen/8k/OSR_us_000_0013_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
samples/listen/8k/OSR_us_000_0057_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
samples/listen/8k/OSR_us_000_0059_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
samples/listen/8k/samplelib_speech_1m_input_8k.wav filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
samples/listen/spectrograms/OSR_cn_000_0072_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
samples/listen/spectrograms/OSR_cn_000_0072_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
samples/listen/spectrograms/OSR_cn_000_0073_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
samples/listen/spectrograms/OSR_cn_000_0073_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
samples/listen/spectrograms/OSR_cn_000_0074_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
samples/listen/spectrograms/OSR_cn_000_0074_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
samples/listen/spectrograms/OSR_cn_000_0075_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
samples/listen/spectrograms/OSR_cn_000_0075_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
samples/listen/spectrograms/OSR_us_000_0010_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
samples/listen/spectrograms/OSR_us_000_0010_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
samples/listen/spectrograms/OSR_us_000_0013_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
samples/listen/spectrograms/OSR_us_000_0013_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
samples/listen/spectrograms/OSR_us_000_0057_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
samples/listen/spectrograms/OSR_us_000_0057_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
samples/listen/spectrograms/OSR_us_000_0059_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
samples/listen/spectrograms/OSR_us_000_0059_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 78 |
+
samples/listen/spectrograms/samplelib_speech_1m_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 79 |
+
samples/listen/spectrograms/samplelib_speech_1m_output_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 80 |
+
samples/listen/spectrograms/speech_2_input_16k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 81 |
+
samples/listen/spectrograms/speech_2_input_8k.png filter=lfs diff=lfs merge=lfs -text
|
| 82 |
+
samples/listen/spectrograms/speech_2_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 83 |
+
samples/listen/spectrograms/speech_2_output_16k_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 84 |
+
samples/listen/spectrograms/speech_2_output_8k_48k.png filter=lfs diff=lfs merge=lfs -text
|
| 85 |
+
samples/listen/spectrograms/speech_2_output_8k_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 86 |
+
samples/listen/spectrograms/speech_3_input_16k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 87 |
+
samples/listen/spectrograms/speech_3_input_8k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 88 |
+
samples/listen/spectrograms/speech_3_output_16k_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
| 89 |
+
samples/listen/spectrograms/speech_3_output_8k_48k_spec.png filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 Jun-Hak Yun
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: axera
|
| 3 |
+
pipeline_tag: audio-to-audio
|
| 4 |
+
base_model: kiriyamaX/FLowHigh_indep_adaptive_400k
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
- zh
|
| 8 |
+
tags:
|
| 9 |
+
- axera
|
| 10 |
+
- ax650
|
| 11 |
+
- npu3
|
| 12 |
+
- flowhigh
|
| 13 |
+
- speech-super-resolution
|
| 14 |
+
- audio-super-resolution
|
| 15 |
+
- bandwidth-extension
|
| 16 |
+
- real-time
|
| 17 |
+
- python
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# FlowHigh.AXERA
|
| 21 |
+
|
| 22 |
+
**8/16 kHz 语音 → 48 kHz 超分 · AX650 NPU3 · Python RTF 0.24(20–60 s 音频)· 2 个 axmodel 共 58 MB · 不做降噪**
|
| 23 |
+
|
| 24 |
+
  [](https://github.com/ZY-2012/FlowHigh.AXERA)
|
| 25 |
+
|
| 26 |
+
- GitHub: https://github.com/ZY-2012/FlowHigh.AXERA
|
| 27 |
+
- 上游: https://github.com/jjunak-yun/FLowHigh_code
|
| 28 |
+
|
| 29 |
+
## 目录
|
| 30 |
+
|
| 31 |
+
- 快速开始
|
| 32 |
+
- 结果
|
| 33 |
+
- 推理速度
|
| 34 |
+
- 数据来源
|
| 35 |
+
- License
|
| 36 |
+
|
| 37 |
+
## 快速开始(AX650 板端)
|
| 38 |
+
|
| 39 |
+
从 HuggingFace 下载 `models/`、`assets/`、`python/`、`samples/`,在包根目录运行:
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
bash run_ax650.sh samples/listen/8k/OSR_us_000_0010_input_8k.wav output.wav
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
输入支持 8 kHz / 16 kHz,输出固定 48 kHz。默认 1-step flow、`std=1e-4`;不做降噪。
|
| 46 |
+
|
| 47 |
+
## 结果
|
| 48 |
+
|
| 49 |
+
### 8 kHz 输入(Open Speech / Samplelib)
|
| 50 |
+
|
| 51 |
+
#### English
|
| 52 |
+
|
| 53 |
+
**OSR_us_000_0010**
|
| 54 |
+
|
| 55 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 56 |
+
|---|---|---|
|
| 57 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_us_000_0010_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0010_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_us_000_0010_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0010_output_48k_spec.png" width="360"> |
|
| 58 |
+
|
| 59 |
+
**OSR_us_000_0013**
|
| 60 |
+
|
| 61 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 62 |
+
|---|---|---|
|
| 63 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_us_000_0013_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0013_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_us_000_0013_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0013_output_48k_spec.png" width="360"> |
|
| 64 |
+
|
| 65 |
+
**OSR_us_000_0057**
|
| 66 |
+
|
| 67 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 68 |
+
|---|---|---|
|
| 69 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_us_000_0057_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0057_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_us_000_0057_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0057_output_48k_spec.png" width="360"> |
|
| 70 |
+
|
| 71 |
+
**OSR_us_000_0059**
|
| 72 |
+
|
| 73 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 74 |
+
|---|---|---|
|
| 75 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_us_000_0059_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0059_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_us_000_0059_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_us_000_0059_output_48k_spec.png" width="360"> |
|
| 76 |
+
|
| 77 |
+
#### Chinese
|
| 78 |
+
|
| 79 |
+
**OSR_cn_000_0072**
|
| 80 |
+
|
| 81 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 82 |
+
|---|---|---|
|
| 83 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_cn_000_0072_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0072_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_cn_000_0072_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0072_output_48k_spec.png" width="360"> |
|
| 84 |
+
|
| 85 |
+
**OSR_cn_000_0073**
|
| 86 |
+
|
| 87 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 88 |
+
|---|---|---|
|
| 89 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_cn_000_0073_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0073_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_cn_000_0073_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0073_output_48k_spec.png" width="360"> |
|
| 90 |
+
|
| 91 |
+
**OSR_cn_000_0074**
|
| 92 |
+
|
| 93 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 94 |
+
|---|---|---|
|
| 95 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_cn_000_0074_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0074_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_cn_000_0074_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0074_output_48k_spec.png" width="360"> |
|
| 96 |
+
|
| 97 |
+
**OSR_cn_000_0075**
|
| 98 |
+
|
| 99 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 100 |
+
|---|---|---|
|
| 101 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/OSR_cn_000_0075_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0075_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/OSR_cn_000_0075_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/OSR_cn_000_0075_output_48k_spec.png" width="360"> |
|
| 102 |
+
|
| 103 |
+
#### Samplelib(1 分钟,频谱图为前 10 s)
|
| 104 |
+
|
| 105 |
+
**samplelib_speech_1m**
|
| 106 |
+
|
| 107 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 108 |
+
|---|---|---|
|
| 109 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/samplelib_speech_1m_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/samplelib_speech_1m_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/samplelib_speech_1m_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/samplelib_speech_1m_output_48k_spec.png" width="360"> |
|
| 110 |
+
|
| 111 |
+
### 16 kHz 参照(人声)
|
| 112 |
+
|
| 113 |
+
同一批人声降采样到 16 kHz 后输入;8k 行为 8 kHz 输入,16k 行为 16 kHz 输入。
|
| 114 |
+
|
| 115 |
+
**speech_2**
|
| 116 |
+
|
| 117 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 118 |
+
|---|---|---|
|
| 119 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/speech_2_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/speech_2_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/speech_2_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/speech_2_output_8k_48k_spec.png" width="360"> |
|
| 120 |
+
| 16k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/16k/speech_2_input_16k.wav"></audio><br><img src="samples/listen/spectrograms/speech_2_input_16k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from16k/speech_2_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/speech_2_output_16k_48k_spec.png" width="360"> |
|
| 121 |
+
|
| 122 |
+
**speech_3**
|
| 123 |
+
|
| 124 |
+
| 版本 | 输入 | FlowHigh 输出 |
|
| 125 |
+
|---|---|---|
|
| 126 |
+
| 8k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/8k/speech_3_input_8k.wav"></audio><br><img src="samples/listen/spectrograms/speech_3_input_8k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from8k/speech_3_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/speech_3_output_8k_48k_spec.png" width="360"> |
|
| 127 |
+
| 16k | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/16k/speech_3_input_16k.wav"></audio><br><img src="samples/listen/spectrograms/speech_3_input_16k_spec.png" width="360"> | <audio controls style="width:220px" src="https://huggingface.co/HY-2012/FlowHigh.AXERA/resolve/main/samples/listen/48k_from16k/speech_3_output_48k.wav"></audio><br><img src="samples/listen/spectrograms/speech_3_output_16k_48k_spec.png" width="360"> |
|
| 128 |
+
|
| 129 |
+
## 推理速度:RTF
|
| 130 |
+
|
| 131 |
+
| 链路 | Python RTF |
|
| 132 |
+
|---|---:|
|
| 133 |
+
| 8/16 kHz → 48 kHz | **0.24** |
|
| 134 |
+
|
| 135 |
+
20–60 s 音频,1-step flow,BigVGAN 1 s 分块、0.2 s overlap。5 s 短音频因分块/启动开销会略高;C++ 运行时尚未提供。
|
| 136 |
+
|
| 137 |
+
## 数据来源
|
| 138 |
+
|
| 139 |
+
- Open Speech Repository(English / Chinese 8k):http://voiptroubleshooter.com/open_speech/index.html
|
| 140 |
+
- Samplelib speech 1m:https://samplelib.com/mp3/sample-speech-1m.mp3
|
| 141 |
+
- 16 kHz 参照:公开人声样例经 48k->16k 降采样。
|
| 142 |
+
|
| 143 |
+
## License
|
| 144 |
+
|
| 145 |
+
MIT;FLowHigh 与 BigVGAN 均为 MIT。模型 checkpoint 来自上游/公开镜像,仓库不重复分发训练权重。
|
assets/time_emb_4.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06284a683d5610206adac80e4764a61f1d77d8cd4d172376513ad5c83d965f0f
|
| 3 |
+
size 16512
|
config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{}
|
models/bigvgan.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4fb5f3a130ef732eea8ef9ac9f365e7bab95d34d176f5926f4a3d21db33306b5
|
| 3 |
+
size 20734384
|
models/flowhigh.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ed959fdc9632a961204eb3ea8872395102505db96d42730a8c0e1fb6189bd12
|
| 3 |
+
size 38297185
|
python/demo_board.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import time
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import soundfile as sf
|
| 7 |
+
|
| 8 |
+
from flowhigh_sdk import audio
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def decode_mel(voc, mel, chunk, overlap):
|
| 12 |
+
hop = chunk - overlap
|
| 13 |
+
wav = None
|
| 14 |
+
for s in range(0, mel.shape[-1], hop):
|
| 15 |
+
m = mel[..., s:s + chunk]
|
| 16 |
+
if m.shape[-1] < chunk:
|
| 17 |
+
m = np.pad(m, ((0, 0), (0, 0), (0, chunk - m.shape[-1])), mode="edge")
|
| 18 |
+
c = voc.run(None, {"mel": np.ascontiguousarray(m)})[0][0, 0]
|
| 19 |
+
if wav is None:
|
| 20 |
+
wav = c
|
| 21 |
+
else:
|
| 22 |
+
n = min(overlap * 480, len(wav), len(c))
|
| 23 |
+
if n > 0:
|
| 24 |
+
fade = np.linspace(0.0, 1.0, n, dtype=np.float32)
|
| 25 |
+
wav[-n:] = wav[-n:] * (1.0 - fade) + c[:n] * fade
|
| 26 |
+
wav = np.concatenate([wav, c[n:]])
|
| 27 |
+
return wav.astype(np.float32)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def main():
|
| 31 |
+
p = argparse.ArgumentParser()
|
| 32 |
+
p.add_argument("--input", required=True)
|
| 33 |
+
p.add_argument("--output", required=True)
|
| 34 |
+
p.add_argument("--models", default="models")
|
| 35 |
+
p.add_argument("--steps", type=int, default=1)
|
| 36 |
+
p.add_argument("--std", type=float, default=1e-4)
|
| 37 |
+
p.add_argument("--seed", type=int, default=0)
|
| 38 |
+
p.add_argument("--chunk", type=int, default=100)
|
| 39 |
+
p.add_argument("--overlap", type=int, default=20)
|
| 40 |
+
p.add_argument("--flow-overlap", type=int, default=50)
|
| 41 |
+
p.add_argument("--time-emb", default="assets/time_emb_4.npy")
|
| 42 |
+
args = p.parse_args()
|
| 43 |
+
|
| 44 |
+
x, sr = sf.read(args.input, always_2d=False)
|
| 45 |
+
if x.ndim > 1:
|
| 46 |
+
x = x.mean(axis=1)
|
| 47 |
+
x = np.asarray(x, dtype=np.float32)
|
| 48 |
+
target = int(round(audio.SR / sr * x.size))
|
| 49 |
+
x = audio.resample(x, sr)
|
| 50 |
+
peak = float(np.max(np.abs(x)))
|
| 51 |
+
if peak > 0:
|
| 52 |
+
x = x / peak
|
| 53 |
+
cond_wave = x.astype(np.float32)
|
| 54 |
+
mel = audio.log_mel(cond_wave)[0].T[None]
|
| 55 |
+
frames = 500
|
| 56 |
+
if mel.shape[-1] < frames:
|
| 57 |
+
mel = np.pad(mel, ((0, 0), (0, 0), (0, frames - mel.shape[-1])), mode="edge")
|
| 58 |
+
total = mel.shape[-1]
|
| 59 |
+
if total > frames:
|
| 60 |
+
n_chunks = (total - frames + (frames - args.flow_overlap) - 1) // (frames - args.flow_overlap) + 1
|
| 61 |
+
padded = frames + (n_chunks - 1) * (frames - args.flow_overlap)
|
| 62 |
+
if padded > total:
|
| 63 |
+
mel = np.pad(mel, ((0, 0), (0, 0), (0, padded - total)), mode="edge")
|
| 64 |
+
padded_total = mel.shape[-1]
|
| 65 |
+
|
| 66 |
+
import axengine
|
| 67 |
+
|
| 68 |
+
flow = axengine.InferenceSession(str(Path(args.models) / "flowhigh.axmodel"))
|
| 69 |
+
voc = axengine.InferenceSession(str(Path(args.models) / "bigvgan.axmodel"))
|
| 70 |
+
emb = np.load(args.time_emb).astype(np.float32)
|
| 71 |
+
rng = np.random.RandomState(args.seed)
|
| 72 |
+
hop = frames - args.flow_overlap
|
| 73 |
+
starts = list(range(0, max(1, padded_total - frames + 1), hop))
|
| 74 |
+
|
| 75 |
+
t0 = time.time()
|
| 76 |
+
flow_ms = []
|
| 77 |
+
out = None
|
| 78 |
+
for s in starts:
|
| 79 |
+
c = mel[..., s:s + frames]
|
| 80 |
+
y = c + args.std * rng.randn(*c.shape).astype(np.float32)
|
| 81 |
+
for i in range(args.steps):
|
| 82 |
+
t1 = time.time()
|
| 83 |
+
v = flow.run(None, {
|
| 84 |
+
"x": np.ascontiguousarray(y),
|
| 85 |
+
"cond": np.ascontiguousarray(c),
|
| 86 |
+
"time_emb": np.ascontiguousarray(emb[i]),
|
| 87 |
+
})[0]
|
| 88 |
+
flow_ms.append((time.time() - t1) * 1000)
|
| 89 |
+
y = y + (1.0 / args.steps) * v
|
| 90 |
+
wav = decode_mel(voc, y, args.chunk, args.overlap)
|
| 91 |
+
if out is None:
|
| 92 |
+
out = wav
|
| 93 |
+
else:
|
| 94 |
+
n = min(args.flow_overlap * 480, len(out), len(wav))
|
| 95 |
+
if n > 0:
|
| 96 |
+
fade = np.linspace(0.0, 1.0, n, dtype=np.float32)
|
| 97 |
+
out[-n:] = out[-n:] * (1.0 - fade) + wav[:n] * fade
|
| 98 |
+
out = np.concatenate([out, wav[n:]])
|
| 99 |
+
out = out[:int(total * 480)]
|
| 100 |
+
out = audio.postprocess(out, cond_wave[:len(out)], len(out))[:target]
|
| 101 |
+
sf.write(args.output, out, audio.SR, subtype="PCM_16")
|
| 102 |
+
dt = time.time() - t0
|
| 103 |
+
print(f"chunks={len(starts)} flow_ms={flow_ms} total_ms={dt*1000:.1f} rtf={dt/(x.size/audio.SR):.4f}")
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
if __name__ == "__main__":
|
| 107 |
+
main()
|
python/flowhigh_sdk/__init__.py
ADDED
|
File without changes
|
python/flowhigh_sdk/audio.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from math import gcd
|
| 3 |
+
|
| 4 |
+
SR = 48000
|
| 5 |
+
N_FFT = 2048
|
| 6 |
+
HOP = 480
|
| 7 |
+
N_MELS = 256
|
| 8 |
+
FMIN = 20.0
|
| 9 |
+
FMAX = 24000.0
|
| 10 |
+
LOG_FLOOR = 1e-5
|
| 11 |
+
MAG_EPS = 1e-9
|
| 12 |
+
|
| 13 |
+
_MEL = None
|
| 14 |
+
_WIN = None
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def _hz_to_mel(f):
|
| 18 |
+
f = np.asarray(f, dtype=np.float64)
|
| 19 |
+
f_sp, min_log_hz = 200.0 / 3.0, 1000.0
|
| 20 |
+
min_log_mel = min_log_hz / f_sp
|
| 21 |
+
logstep = np.log(6.4) / 27.0
|
| 22 |
+
mel = np.empty_like(f)
|
| 23 |
+
lin = f < min_log_hz
|
| 24 |
+
mel[lin] = f[lin] / f_sp
|
| 25 |
+
mel[~lin] = min_log_mel + np.log(f[~lin] / min_log_hz) / logstep
|
| 26 |
+
return mel
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _mel_to_hz(m):
|
| 30 |
+
m = np.asarray(m, dtype=np.float64)
|
| 31 |
+
f_sp, min_log_hz = 200.0 / 3.0, 1000.0
|
| 32 |
+
min_log_mel = min_log_hz / f_sp
|
| 33 |
+
logstep = np.log(6.4) / 27.0
|
| 34 |
+
hz = np.empty_like(m)
|
| 35 |
+
lin = m < min_log_mel
|
| 36 |
+
hz[lin] = m[lin] * f_sp
|
| 37 |
+
hz[~lin] = min_log_hz * np.exp(logstep * (m[~lin] - min_log_mel))
|
| 38 |
+
return hz
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def mel_filterbank():
|
| 42 |
+
global _MEL
|
| 43 |
+
if _MEL is None:
|
| 44 |
+
freqs = np.linspace(0.0, SR / 2.0, N_FFT // 2 + 1)
|
| 45 |
+
edges = np.linspace(_hz_to_mel([FMIN])[0], _hz_to_mel([FMAX])[0], N_MELS + 2)
|
| 46 |
+
hz = _mel_to_hz(edges)
|
| 47 |
+
fb = np.zeros((N_MELS, freqs.shape[0]), dtype=np.float32)
|
| 48 |
+
for m in range(N_MELS):
|
| 49 |
+
left, center, right = hz[m], hz[m + 1], hz[m + 2]
|
| 50 |
+
up = (freqs - left) / (center - left)
|
| 51 |
+
down = (right - freqs) / (right - center)
|
| 52 |
+
fb[m] = np.maximum(0.0, np.minimum(up, down)) * (2.0 / max(1e-8, right - left))
|
| 53 |
+
_MEL = fb
|
| 54 |
+
return _MEL
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def hann():
|
| 58 |
+
global _WIN
|
| 59 |
+
if _WIN is None:
|
| 60 |
+
_WIN = np.hanning(N_FFT + 1)[:-1].astype(np.float64)
|
| 61 |
+
return _WIN
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def log_mel(audio):
|
| 65 |
+
x = np.asarray(audio, dtype=np.float64).reshape(-1)
|
| 66 |
+
pad = (N_FFT - HOP) // 2
|
| 67 |
+
x = np.pad(x, (pad, pad), mode="reflect")
|
| 68 |
+
frames = 1 + (x.size - N_FFT) // HOP
|
| 69 |
+
idx = np.arange(N_FFT)[None, :] + HOP * np.arange(frames)[:, None]
|
| 70 |
+
spec = np.fft.rfft(x[idx] * hann(), n=N_FFT, axis=1).T
|
| 71 |
+
mag = np.sqrt(spec.real ** 2 + spec.imag ** 2 + MAG_EPS)
|
| 72 |
+
mel = np.log(np.clip(mel_filterbank() @ mag, LOG_FLOOR, None))
|
| 73 |
+
return mel.T[None].astype(np.float32)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def stft(x, center=True, pad_mode="constant"):
|
| 77 |
+
x = np.asarray(x, dtype=np.float64).reshape(-1)
|
| 78 |
+
if center:
|
| 79 |
+
p = N_FFT // 2
|
| 80 |
+
x = np.pad(x, (p, p), mode=pad_mode)
|
| 81 |
+
frames = 1 + (x.size - N_FFT) // HOP
|
| 82 |
+
idx = np.arange(N_FFT)[None, :] + HOP * np.arange(frames)[:, None]
|
| 83 |
+
return np.fft.rfft(x[idx] * hann(), n=N_FFT, axis=1).T
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def istft(spec, length=None, center=True):
|
| 87 |
+
spec = np.asarray(spec)
|
| 88 |
+
frames = np.fft.irfft(spec.T, n=N_FFT, axis=1) * hann()
|
| 89 |
+
out_len = N_FFT + HOP * (frames.shape[0] - 1)
|
| 90 |
+
ola = np.zeros(out_len, dtype=np.float64)
|
| 91 |
+
wsum = np.zeros(out_len, dtype=np.float64)
|
| 92 |
+
w2 = hann() ** 2
|
| 93 |
+
for i in range(frames.shape[0]):
|
| 94 |
+
s = i * HOP
|
| 95 |
+
ola[s:s + N_FFT] += frames[i]
|
| 96 |
+
wsum[s:s + N_FFT] += w2
|
| 97 |
+
ola /= np.where(wsum > 1e-11, wsum, 1.0)
|
| 98 |
+
if center:
|
| 99 |
+
ola = ola[N_FFT // 2:len(ola) - N_FFT // 2]
|
| 100 |
+
if length is not None:
|
| 101 |
+
if ola.size > length:
|
| 102 |
+
ola = ola[:length]
|
| 103 |
+
elif ola.size < length:
|
| 104 |
+
ola = np.pad(ola, (0, length - ola.size))
|
| 105 |
+
return ola.astype(np.float32)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def cutoff_bin(spec):
|
| 109 |
+
energy = np.cumsum(np.abs(spec).sum(axis=-1))
|
| 110 |
+
if energy[-1] <= 0:
|
| 111 |
+
return 0
|
| 112 |
+
limit = energy[-1] * 0.99
|
| 113 |
+
below = np.nonzero(energy < limit)[0]
|
| 114 |
+
return int(below[-1]) + 1 if below.size else 0
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def postprocess(pred, src, length):
|
| 118 |
+
ps = stft(pred, center=True, pad_mode="constant")
|
| 119 |
+
ss = stft(src, center=True, pad_mode="constant")
|
| 120 |
+
n = min(ps.shape[-1], ss.shape[-1])
|
| 121 |
+
ps, ss = ps[:, :n], ss[:, :n]
|
| 122 |
+
cr = cutoff_bin(ss)
|
| 123 |
+
merged = ps.copy()
|
| 124 |
+
merged[:cr] = ss[:cr]
|
| 125 |
+
out = istft(merged, length=length, center=True)
|
| 126 |
+
peak = np.max(np.abs(out))
|
| 127 |
+
if peak > 0:
|
| 128 |
+
out = out / peak * 0.99
|
| 129 |
+
return out.astype(np.float32)
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def resample(x, sr_in, sr_out=SR):
|
| 133 |
+
x = np.asarray(x, dtype=np.float32).reshape(-1)
|
| 134 |
+
if sr_in == sr_out:
|
| 135 |
+
return x
|
| 136 |
+
g = gcd(int(sr_out), int(sr_in))
|
| 137 |
+
from scipy.signal import resample_poly
|
| 138 |
+
return resample_poly(x, sr_out // g, sr_in // g).astype(np.float32)
|
python/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy
|
| 2 |
+
scipy
|
| 3 |
+
soundfile
|
reports/quantization.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowHigh AX650 quantization report
|
| 2 |
+
|
| 3 |
+
## Target
|
| 4 |
+
|
| 5 |
+
- Board: AX650N, NPU3, axengine 2.12.0s, compiler 8.0.
|
| 6 |
+
- Flow: U16 activations / S8 weights, 38 MB.
|
| 7 |
+
- BigVGAN: U16 activations / S8 weights, 20 MB.
|
| 8 |
+
- Input: 8 kHz / 16 kHz -> 48 kHz.
|
| 9 |
+
- No denoising.
|
| 10 |
+
|
| 11 |
+
## Graph split
|
| 12 |
+
|
| 13 |
+
```text
|
| 14 |
+
host: resample_poly -> log-mel [1,256,T] -> 1-step flow -> BigVGAN chunks -> STFT merge
|
| 15 |
+
NPU: flow velocity (37 MB) + BigVGAN 1 s chunks (20 MB)
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
The flow NPU input is channel-first `[1,256,500]`; the wrapper transposes to `[1,500,256]` internally. This is required: Pulsar2 lowers 3D tensors channel-first, and feeding `[1,500,256]` directly makes attention run on the wrong axis.
|
| 19 |
+
|
| 20 |
+
## Numerical checks
|
| 21 |
+
|
| 22 |
+
| Check | Result |
|
| 23 |
+
|---|---|
|
| 24 |
+
| Flow ONNX vs PyTorch velocity | max err 1.5e-4 |
|
| 25 |
+
| Flow U16/S8 on board vs ONNX | SNR 32.96 dB, corr 0.99977 |
|
| 26 |
+
| Flow latency, 5 s | 21 ms (after warmup) |
|
| 27 |
+
| BigVGAN ONNX vs PyTorch | max err 8.2e-6 |
|
| 28 |
+
| BigVGAN U16/S8 on board vs ONNX, 1 s | SNR 20.55 dB, corr 0.99560 |
|
| 29 |
+
| BigVGAN latency, 1 s | ~93 ms |
|
| 30 |
+
| BigVGAN chunk overlap | 0.2 s; boundary jump reduced from 0.44 to 0.005 |
|
| 31 |
+
|
| 32 |
+
BigVGAN is the sensitive part; its direct waveform SNR is low, but the final speech quality after spectral merging is close to the FP32 pipeline.
|
| 33 |
+
|
| 34 |
+
## Full pipeline quality
|
| 35 |
+
|
| 36 |
+
VCTK `p232_013`, 48 kHz reference. Board uses 1-step flow with `std=1e-4`, BigVGAN 1 s / 0.2 s overlap. Baseline and board use different RNG seeds, so the PESQ/LSD comparison is indicative; flow and BigVGAN SNR rows are strict same-input comparisons.
|
| 37 |
+
|
| 38 |
+
| Input | Pipeline | PESQ-WB | STOI | Mel LSD |
|
| 39 |
+
|---|---|---|---:|---:|
|
| 40 |
+
| 8 kHz | PyTorch FP32 | 3.872 | 0.9981 | 2.323 |
|
| 41 |
+
| 8 kHz | AX650 U16/S8 | **3.876** | **0.9982** | 2.333 |
|
| 42 |
+
| 16 kHz | PyTorch FP32 | 4.570 | 1.0000 | 2.315 |
|
| 43 |
+
| 16 kHz | AX650 U16/S8 | **4.573** | **1.0000** | 2.302 |
|
| 44 |
+
|
| 45 |
+
## Speed
|
| 46 |
+
|
| 47 |
+
5 s input, Python/axengine, one flow step:
|
| 48 |
+
|
| 49 |
+
| Stage | Time |
|
| 50 |
+
|---|---:|
|
| 51 |
+
| Flow | 33 ms |
|
| 52 |
+
| BigVGAN (6 x 1 s chunks) | 578 ms |
|
| 53 |
+
| Host STFT/mel/postprocess | ~600 ms |
|
| 54 |
+
| Total | 0.94–1.22 s |
|
| 55 |
+
| RTF | 0.19–0.24 |
|
| 56 |
+
|
| 57 |
+
The current runtime is Python-only. Moving STFT/postprocess to C++ and using a native flow/vocoder loop is the next optimization; the NPU portion itself is 0.61 s for 5 s.
|
| 58 |
+
|
| 59 |
+
## Long audio
|
| 60 |
+
|
| 61 |
+
The flow graph is fixed at 500 mel frames (5 s). Longer audio is processed in 5 s chunks with 0.5 s overlap and waveform crossfade; BigVGAN uses 1 s chunks with 0.2 s overlap. The 60 s Samplelib input was processed end-to-end with no boundary clicks above the normal waveform derivative.
|
| 62 |
+
|
| 63 |
+
## Limitations
|
| 64 |
+
|
| 65 |
+
- The 5 s flow chunk is a hard graph size; longer context would need a different compiled graph.
|
| 66 |
+
- No denoising; FLowHigh is BWE only.
|
| 67 |
+
- C++ runtime is not included in this first quantization milestone.
|
run_ax650.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
cd "$(dirname "$0")"
|
| 4 |
+
if [ "$#" -ge 2 ] && [ "${1#-}" = "$1" ]; then
|
| 5 |
+
IN="$1"; OUT="$2"; shift 2
|
| 6 |
+
exec python3 python/demo_board.py --models models --steps 1 --std 0.0001 --input "$IN" --output "$OUT" "$@"
|
| 7 |
+
fi
|
| 8 |
+
exec python3 python/demo_board.py --models models --steps 1 --std 0.0001 "$@"
|
samples/listen/16k/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/16k/speech_3_input_16k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19cb7158760a383a60f1c2e5de23a780331f492fd5a7ccc63a58cadb8ad2f804
|
| 3 |
+
size 163884
|
samples/listen/48k_from16k/speech_2_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9dddb1324a6bd655a1d3e3eebe426ebe7fd1f27cecb5691a8a1c9c65a6900b78
|
| 3 |
+
size 491564
|
samples/listen/48k_from16k/speech_3_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ea134e4f9a4c1ce8c683f1b4c8d867614c48fd9c7d86012c5b28f4eac929eba9
|
| 3 |
+
size 491564
|
samples/listen/48k_from8k/OSR_cn_000_0072_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3aacb425e8d754df060a22409847c89bae4100837eae32326e7d206bcc607afa
|
| 3 |
+
size 1916204
|
samples/listen/48k_from8k/OSR_cn_000_0073_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ccd4b0a34f5a6cc92c944410cb2d20a68ccf4a875f3a34ef8597ac2a205b638
|
| 3 |
+
size 2102444
|
samples/listen/48k_from8k/OSR_cn_000_0074_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f34689207317fa1b6d6bbf5cbf9f8214fca395f7883161dea7258e4e3b4a91a7
|
| 3 |
+
size 2207084
|
samples/listen/48k_from8k/OSR_cn_000_0075_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e5845b5def78204cfae9d3fb4dfa5bf8604bf2f0537ad5abdf2cb7c57b77822
|
| 3 |
+
size 2389484
|
samples/listen/48k_from8k/OSR_us_000_0010_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:020b7219f36a61dc11ea0b003a8249ee7de2b8ed4cb4b0a14c27f7250836c18a
|
| 3 |
+
size 3227564
|
samples/listen/48k_from8k/OSR_us_000_0013_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d23124c3e9a8415a9ca48de6b3c432fb2534f91d660b0ef680a86fdc156aa2c4
|
| 3 |
+
size 3123884
|
samples/listen/48k_from8k/OSR_us_000_0057_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11c50ba9a97219286e7e15aaf58043083e871fa36eafdeb0cc571656f821a23a
|
| 3 |
+
size 3768044
|
samples/listen/48k_from8k/OSR_us_000_0059_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b72a16bda85904b21786ecea508bbe847e1579dc2c34f558284ff765bbd36a2
|
| 3 |
+
size 5348204
|
samples/listen/48k_from8k/samplelib_speech_1m_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f87bcb7e77799e390f1017231d35931bef3c6d7c1262334c7cc775189a21bdbe
|
| 3 |
+
size 5760044
|
samples/listen/48k_from8k/speech_2_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba2dcda972762f4369839be6776fd77c7291edfd00a7b164ef8ab433963e3641
|
| 3 |
+
size 491564
|
samples/listen/48k_from8k/speech_3_output_48k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6aa796c46e7f7938c242018ba818c97dabedf29cf74c02c298be73658d6ff77b
|
| 3 |
+
size 491564
|
samples/listen/8k/OSR_cn_000_0072_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7e2e6c7a0476d0286c6b1df92d15ab938888dfecd73efb29e4a0b82740fa761
|
| 3 |
+
size 319526
|
samples/listen/8k/OSR_cn_000_0073_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ffacc5400d699ff1b84917308a4f9f0eb996a7957d4ee4bb126c7d3a6ee1e375
|
| 3 |
+
size 350544
|
samples/listen/8k/OSR_cn_000_0074_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ef91f9f846a94d5e617fdba65a9acbb1eaffcbbafee50880e92bb857e171c7f
|
| 3 |
+
size 367988
|
samples/listen/8k/OSR_cn_000_0075_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3fd3b56518d3aed721b5e3c98c7492796eb85d225b52ee325053d9d595edcb5e
|
| 3 |
+
size 398442
|
samples/listen/8k/OSR_us_000_0010_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4bf9becd046d7aedb6d05b6e12347a6294a44f74d263089c636fb0a2b1e6561
|
| 3 |
+
size 538014
|
samples/listen/8k/OSR_us_000_0013_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3af3f5df07da603b7a421a345aad023df28c862ba92f68af360cc8c64c71436e
|
| 3 |
+
size 520730
|
samples/listen/8k/OSR_us_000_0057_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ebf286a093ca75e7f53b26180c6e54e7f179680b19d57a52f19516dd036381fe
|
| 3 |
+
size 628192
|
samples/listen/8k/OSR_us_000_0059_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:84520e52d7f8e7fadbb0d3bfbf18ddf80ff8bd7862d9287a48bfe8060223e554
|
| 3 |
+
size 891442
|
samples/listen/8k/samplelib_speech_1m_input_8k.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:41fa574399ab8fa2f9263be1d386449f884627d205e72c310233c481cacf9b57
|
| 3 |
+
size 960164
|
samples/listen/8k/speech_2_input_8k.wav
ADDED
|
Binary file (82 kB). View file
|
|
|
samples/listen/8k/speech_3_input_8k.wav
ADDED
|
Binary file (82 kB). View file
|
|
|
samples/listen/spectrograms/OSR_cn_000_0072_input_8k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0072_output_48k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0073_input_8k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0073_output_48k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0074_input_8k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0074_output_48k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0075_input_8k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_cn_000_0075_output_48k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_us_000_0010_input_8k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_us_000_0010_output_48k_spec.png
ADDED
|
Git LFS Details
|
samples/listen/spectrograms/OSR_us_000_0013_input_8k_spec.png
ADDED
|
Git LFS Details
|