Views
No views yet
1@inproceedings{vu2025zeroshottexttospeechvietnamese,
2 title={Zero-Shot Text-to-Speech for Vietnamese},
3 author={Thi Vu and Linh The Nguyen and Dat Quoc Nguyen},
4 year={2025},
5 booktitle={Proceedings of ACL},
6}1import torch
2from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
4device = "cuda:0" if torch.cuda.is_available() else "cpu"
5
6model_name = "thivux/PhoTextNormalization"
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForSeq2SeqLM.from_pretrained(model_name).to(device)
9
10text = 'Một tháng có 30 hoặc 31 ngày, riêng tháng 2 có 28 ngày.'
11inputs = tokenizer(text, return_tensors="pt", padding=True,
12 truncation=True, max_length=1024).to(device)
13
14# Generate translations
15with torch.no_grad():
16 translated_tokens = model.generate(
17 **inputs, max_length=1024, num_beams=5)
18
19# Decode
20decoded_outputs = [tokenizer.decode(output, skip_special_tokens=True)
21 for output in translated_tokens]
22
23# decoded_outputs: ['một tháng có ba mươi hoặc ba mươi mốt ngày, riêng tháng hai có hai tám ngày.']
24print(f'decoded_outputs: {decoded_outputs}')