Huggingface_Hack / test_modules /supertonic_clone_demo.py
sshtel's picture
feat: integrate Supertonic TTS with sentence-level chunk streaming
5f8f265
Raw
History Blame Contribute Delete
2.19 kB
from supertonic import TTS
from supertonic import pipeline
import numpy as np
from pathlib import Path
tts = TTS(auto_download=True)
# Load a locally downloaded custom voice style JSON.
json_path = Path(__file__).resolve().parent / "recorded_voice_supertonic-3.json"
style = pipeline.load_voice_style_from_json_file(str(json_path))
# text = "A gentle breeze moved through the open window while everyone listened to the story."
# text = "Hello, Bay Area K group Vibe coding members. This is generated by Supertonic model on my local machine"
# text = "To clarify if this model is locally inferenced, I turned off wifi and generated this audio"
# text = "Testing my clone model voice TTS in English"
text = """
Long before the advent of the printing press or the digital screen, humanity’s fundamental drive to communicate birthed the earliest systems of recorded thought.
It began with pictographs etched into the cool, unyielding stone of ancient caves, where early storytellers captured the essence of their daily lives, spiritual beliefs, and conquests.
These simple drawings were not mere decoration;
they were the very first seeds of human collaboration, allowing knowledge to transcend the boundaries of a single lifetime.
As human societies grew in complexity, so did their methods of encoding information.
The transition from crude cave art to structured written systems marked a monumental leap in cognitive evolution.
In the fertile crescent of Mesopotamia, the need to track agricultural surplus and administrative records led to the development of cuneiform, a system of wedge-shaped marks pressed into damp clay tablets.
This was the dawn of history—the moment when human thought could be permanently preserved, retrieved, and scrutinized by others.
"""
wav, duration = tts.synthesize(text, voice_style=style, lang="en")
# text = "한국어 보이스 클로닝 테스트. 하나둘셋 하나둘셋. 동해물과 백두산이 마르고 닳도록"
# wav, duration = tts.synthesize(text, voice_style=style, lang="ko")
tts.save_audio(wav, "clone_output_04.wav")
duration_sec = float(np.asarray(duration).reshape(-1)[0])
print(f"Generated {duration_sec:.2f}s of audio")