Spaces:
Runtime error
Runtime error
Download src/sbv2/text_encoder.py from buchi-stdesign/style-bert-vits2-fastapi: direct link, hf CLI and curl.
- Browser
- Download file 402 Bytes
-
https://huggingface.co/spaces/buchi-stdesign/style-bert-vits2-fastapi/resolve/main/src/sbv2/text_encoder.py
- Command line
-
hf download hf://spaces/buchi-stdesign/style-bert-vits2-fastapi/src/sbv2/text_encoder.py
-
curl -L -o text_encoder.py https://huggingface.co/spaces/buchi-stdesign/style-bert-vits2-fastapi/resolve/main/src/sbv2/text_encoder.py
402 Bytes
| # text_encoder.py | |
| from src.sbv2.text.symbols import symbols | |
| _symbol_to_id = {s: i for i, s in enumerate(symbols)} | |
| _id_to_symbol = {i: s for i, s in enumerate(symbols)} | |
| def text_to_sequence(text): | |
| sequence = [_symbol_to_id[s] for s in text if s in _symbol_to_id] | |
| return sequence | |
| def sequence_to_text(sequence): | |
| return ''.join([_id_to_symbol[i] for i in sequence if i in _id_to_symbol]) | |