Download python/run_board_samples.py from HY-2012/M5-TTS-Lite.AXERA: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/HY-2012/M5-TTS-Lite.AXERA/resolve/main/python/run_board_samples.py
- Command line
-
hf download hf://HY-2012/M5-TTS-Lite.AXERA/python/run_board_samples.py
-
curl -L -o run_board_samples.py https://huggingface.co/HY-2012/M5-TTS-Lite.AXERA/resolve/main/python/run_board_samples.py
1.23 kB
| #!/usr/bin/env python3 | |
| """Generate the published sample set (run on the AX650 board).""" | |
| import os | |
| import sys | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from m5_ax import M5AX, write_wav | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| CASES = [ | |
| ("zh_default", "你好,欢迎使用我们的语音合成模型。", "Chinese", 1234), | |
| ("en_default", "The voice generated by this model sounds amazing!", "English", 1234), | |
| ("zh_long", "今天天气很好,我们一起去公园散步吧。公园里有很多花,还有一条小河,河水非常清澈。", "Chinese", 42), | |
| ] | |
| PROMPT_TEXT = "猪携带该疾病,然后通过蚊子传染给人类。" | |
| def main(): | |
| tts = M5AX(os.path.join(HERE, "..", "models"), os.path.join(HERE, "..", "models", "assets")) | |
| out = os.path.join(HERE, "..", "samples", "listen") | |
| os.makedirs(out, exist_ok=True) | |
| for name, text, lang, seed in CASES: | |
| wav = tts.synthesize(text, os.path.join(HERE, "..", "samples", "aslp_default_voice.wav"), | |
| PROMPT_TEXT, lang=lang, seed=seed) | |
| write_wav(os.path.join(out, name + ".wav"), wav, tts.sr) | |
| print(name, tts.last_timing) | |
| if __name__ == "__main__": | |
| main() | |