import os, shutil, sys, torch, soundfile as sffrom huggingface_hub import snapshot_download # 1. base model -> BiCodec + wav2vec2 + config.yamlbase = snapshot_download("unsloth/Spark-TTS-0.5B")# 2. this fine-tuned LLMllm = snapshot_download("HossamRizk/Temsah-TTS") # 3. assemble a Spark-servable model dir (base layout, our LLM swapped in)root = "Temsah-TTS-spark"shutil.rmtree(root, ignore_errors=True); os.makedirs(root)shutil.copy(f"{base}/config.yaml", f"{root}/config.yaml")shutil.copytree(f"{base}/BiCodec", f"{root}/BiCodec")shutil.copytree(f"{base}/wav2vec2-large-xlsr-53", f"{root}/wav2vec2-large-xlsr-53")shutil.copytree(llm, f"{root}/LLM") # 4. synthesize (needs a reference clip of the target speaker for the voice)sys.path.append("Spark-TTS")from cli.SparkTTS import SparkTTS tts = SparkTTS(root, device="cuda:0" if torch.cuda.is_available() else "cpu")wav = tts.inference( "النهارده هنتكلم عن موضوع مهم جدا يخص كل واحد فينا", prompt_speech_path="reference_clip.wav", # a few seconds of the target speaker)sf.write("output.wav", wav, 16000)