Views
No views yet
qwen_tts package installed (or clone the Qwen3-TTS repository):pip install qwen-tts torch soundfilespeaker="batman" exactly as shown below:1import soundfile as sf
2import torch
3from qwen_tts import Qwen3TTSModel
4
5# 1. Load the fine-tuned model
6print("Loading model...")
7model = Qwen3TTSModel.from_pretrained(
8 "Karthikappi0011/batman-english-qwen3-tts",
9 device_map="cuda", # Change to "cpu" or "mps" if on Mac
10 torch_dtype=torch.bfloat16,
11 attn_implementation="sdpa", # Or "flash_attention_2" if supported
12)
13
14# 2. Provide the text
15text = "I am vengeance. I am the night. I am Batman. The city needs me, and I will not fail."
16
17# 3. Generate the audio
18print("Generating audio...")
19wavs, sr = model.generate_custom_voice(
20 text=text,
21 speaker="batman", # Must be "batman" to trigger the custom voice embedding
22 language="English", # Or "Auto"
23)
24
25# 4. Save to disk
26output_path = "batman_output.wav"
27sf.write(output_path, wavs[0], sr)
28print(f"Saved generated speech to {output_path}")batman