Views
No views yet
facebook/mms-tts-shn model from Hugging Face, which provides a strong multilingual foundation.metadata_wav.csv to correctly extract audio file paths and transcriptions.ShanTTSDataset for seamless integration with the Hugging Face datasets library.ၷ, ၹ, ၻ, ၾ, ႊ, ရ, ႂ, ႆ) to the base model's tokenizer vocabulary to ensure comprehensive character coverage.preprocessor_config.json was correctly placed and updated model configuration files (e.g., vocab_size) to reflect tokenizer changes.transformers library:1from transformers import VitsModel, VitsTokenizer
2import torch
3import scipy.io.wavfile as wavfile
4
5# Specify the path to your fine-tuned model directory
6# If you've uploaded it to Hugging Face, you can use "your-hf-username/your-model-name"
7MODEL_PATH = "/content/shan-mms-vits-output" # Example: local path after fine-tuning
8
9# Load the model and tokenizer
10model = VitsModel.from_pretrained(MODEL_PATH)
11tokenizer = VitsTokenizer.from_pretrained(MODEL_PATH)
12
13# Define the Shan text you want to synthesize
14text = "မိူင်းတႆးၵေႃႈပႆႇပႃႈလႆႈၶိုၼ်း ပူၼ်ႉမႃးသိပ်းပီယဝ်ႉလူး…" # Example Shan text
15
16# Tokenize the input text
17inputs = tokenizer(text, return_tensors="pt")
18
19# Generate the speech waveform
20with torch.no_grad():
21 # Note: ensure 'noise_scale', 'noise_scale_duration', 'length_scale' are not passed
22 # if the model's forward method does not explicitly accept them.
23 output = model(**inputs).waveform
24
25# Save the generated audio to a WAV file
26wavfile.write(
27 "generated_shan_audio.wav",
28 rate=model.config.sampling_rate,
29 data=output[0].cpu().numpy() # Extract the first waveform and convert to numpy
30)
31
32print("Audio generated and saved to generated_shan_audio.wav")
33
34# In a Colab environment, you can play the audio directly:
35# from IPython.display import Audio, display
36# display(Audio("generated_shan_audio.wav", autoplay=True))