ThuraAung1601/edited-common-voice-with-ipa
Viewer • Updated • 40.1k • 82 • 1
How to use ThuraAung1601/speecht5_for_thai_with_ipa_tts_v1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-to-audio", model="ThuraAung1601/speecht5_for_thai_with_ipa_tts_v1") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, AutoModelForTextToSpectrogram
processor = AutoProcessor.from_pretrained("ThuraAung1601/speecht5_for_thai_with_ipa_tts_v1")
model = AutoModelForTextToSpectrogram.from_pretrained("ThuraAung1601/speecht5_for_thai_with_ipa_tts_v1", device_map="auto")This model is a fine-tuned version of microsoft/speecht5_tts on the Edited Thai Common Voice dataset. It achieves the following results on the evaluation set:
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech
import numpy as np
tts_model = SpeechT5ForTextToSpeech.from_pretrained("ThuraAung1601/speecht5_for_thai_with_ipa_tts_v1")
ipa_processor = SpeechT5Processor.from_pretrained("ThuraAung1601/speecht5_for_thai_with_ipa_tts_v1")
ipa_tokenizer = ipa_processor.tokenizer
ipa_tokenizer.decode(ipa_tokenizer(text)["input_ids"])
loaded_np = np.load("speaker_embedding_304.npy")
speaker_embedding = torch.tensor(loaded_np)
text = "ที่ข้าพเจ้าได้เคยล่วงเกินท่านไว้"
from pythainlp.tokenize import word_tokenize
from pythainlp.transliterate import transliterate
def thai2ipa_dict(text):
result = []
for word in word_tokenize(text):
result.append(transliterate(word).replace(" ", ""))
return "".join(result)
ipa = thai2ipa_dict(text)
model_input = ipa_processor(text=ipa, return_tensors="pt")
spectrogram = tts_model.generate_speech(model_input["input_ids"], speaker_embedding)
from transformers import SpeechT5HifiGan
the_vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
with torch.no_grad():
speech = the_vocoder(spectrogram)
import soundfile as sf
sf.write("output.wav", speech.numpy(), samplerate=16000)
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.5418 | 0.5601 | 1000 | 0.4969 |
| 0.5335 | 1.1199 | 2000 | 0.4889 |
| 0.5177 | 1.6799 | 3000 | 0.4818 |
| 0.5188 | 2.2397 | 4000 | 0.4800 |
| 0.5067 | 2.7998 | 5000 | 0.4738 |
| 0.5072 | 3.3596 | 6000 | 0.4730 |
Base model
microsoft/speecht5_tts