Download python/demo.py from HY-2012/opusBWE.AXERA: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/HY-2012/opusBWE.AXERA/resolve/main/python/demo.py
- Command line
-
hf download hf://HY-2012/opusBWE.AXERA/python/demo.py
-
curl -L -o demo.py https://huggingface.co/HY-2012/opusBWE.AXERA/resolve/main/python/demo.py
1.15 kB
| #!/usr/bin/env python3 | |
| """OpusBWE.AXERA demo: 16 kHz wav -> 48 kHz wav. | |
| The neural feature net runs on the AX650 NPU; the DSP synthesis is the bundled | |
| C++ backend. This wrapper starts `bin/bwe_ax650` with the right environment. | |
| """ | |
| import argparse | |
| import os | |
| import subprocess | |
| import sys | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| def main(): | |
| ap = argparse.ArgumentParser(description="OpusBWE.AXERA 16k -> 48k bandwidth extension") | |
| ap.add_argument("input", help="input wav (16 kHz)") | |
| ap.add_argument("output", help="output wav (48 kHz)") | |
| ap.add_argument("--model", default=os.path.join(ROOT, "models", "bwe_feature_net.axmodel")) | |
| ap.add_argument("--bin", default=os.path.join(ROOT, "bin", "bwe_ax650")) | |
| args = ap.parse_args() | |
| if not os.path.isfile(args.bin): | |
| sys.exit(f"backend not found: {args.bin}") | |
| env = dict(os.environ) | |
| env["LD_LIBRARY_PATH"] = "/soc/lib:" + env.get("LD_LIBRARY_PATH", "") | |
| cmd = [args.bin, args.model, args.input, args.output] | |
| print("+", " ".join(cmd)) | |
| sys.exit(subprocess.run(cmd, env=env).returncode) | |
| if __name__ == "__main__": | |
| main() | |