Views
No views yet
1from unsloth import FastModel
2import torch
3
4# Load the fine-tuned Spark-TTS model and tokenizer from Hugging Face Hub
5model, tokenizer = FastModel.from_pretrained(
6 "sureshbeekhani/spark-tts-0.5b-finetune-16bit",
7 max_seq_length=2048, # Adjust based on your needs
8 dtype=torch.bfloat16, # Use bfloat16 for LoRA compatibility and efficiency
9 full_finetuning=False, # Set to False if you want to use the model for inference only
10)
11
12# Example text input for speech synthesis
13text = "Hello, welcome to the Spark-TTS fine-tuned model demo!"
14
15# Tokenize the input text
16inputs = tokenizer(text, return_tensors="pt")
17
18# Generate speech output from the model
19# Note: Adjust this to your model’s specific generate method if applicable
20outputs = model.generate(**inputs)
21
22# Process or save outputs as needed (e.g., convert to audio waveform)
23# This part depends on your model’s output format and synthesis pipeline
24
25print("Inference completed successfully.")
26
27# Limitations
28LoRA fine-tuning is supported only with bfloat16 precision.
29
30Designed primarily for speech synthesis; may not perform well for unrelated NLP tasks.
31
32Usage in production should be tested carefully for latency and quality trade-offs.
33
34#License
35
36This model is licensed under the MIT License.
37If you want, I can help generate a README.md file or add badges and additional sections!