Files
supertonic/py/example_pypi.py
fbdp1202 912c54b435 fix: Supertonic 3 compatibility across all language examples
- README Quick Start: format `duration[0]` instead of the ndarray itself
  (numpy refuses `f"{ndarray:.2f}"`; matches official `dur[0]:.2f` pattern)
- py/example_pypi.py: print synthesized duration to mirror the docstring example
- Add `"na"` to AVAILABLE_LANGS / Languages.Available / availableLangs
  across all 11 runtimes (Python/Node/Web/Java/C++/C#/Go/Swift/Rust/Flutter/iOS)
  so the language-agnostic fallback advertised in the README actually passes
  per-runtime lang validation before being sent to the v3 ONNX duration predictor

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 23:22:42 +09:00

17 lines
603 B
Python

from supertonic import TTS
# Note: First run downloads model automatically (~260MB)
tts = TTS(auto_download=True)
# Get a voice style
style = tts.get_voice_style(voice_name="M4")
# Generate speech
text = "This morning, I took a walk in the park, and the sound of the birds and the breeze was so pleasant that I stopped for a long time just to listen."
wav, duration = tts.synthesize(text, voice_style=style)
# wav: np.ndarray, shape = (1, num_samples)
# duration: np.ndarray, shape = (1,)
# Save to file
tts.save_audio(wav, "results/example_pypi.wav")
print(f"Generated {duration[0]:.2f}s of audio")