-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdemo.py
More file actions
58 lines (48 loc) · 1.68 KB
/
demo.py
File metadata and controls
58 lines (48 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Simple demo script for PyThaiTTS
This script demonstrates Thai text-to-speech synthesis using PyThaiTTS.
"""
from pythaitts import TTS
def main():
print("=" * 60)
print("PyThaiTTS Demo - Thai Text-to-Speech")
print("=" * 60)
print()
# Initialize TTS with default model (lunarlist_onnx)
print("Initializing TTS model (lunarlist_onnx)...")
try:
tts = TTS()
print("✓ TTS model loaded successfully!")
print()
# Sample Thai text
text = "สวัสดีครับ ยินดีต้อนรับสู่ PyThaiTTS"
print(f"Input text: {text}")
print()
# Generate speech and save to file
import datetime
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
output_file = f"output_{timestamp}.wav"
print(f"Generating speech and saving to {output_file}...")
result = tts.tts(text, filename=output_file)
print(f"✓ Speech generated successfully!")
print(f"Output saved to: {result}")
print()
# Also demonstrate getting waveform
print("Generating waveform...")
waveform = tts.tts(text, return_type="waveform")
print(f"✓ Waveform generated successfully!")
print(f"Waveform shape: {waveform.shape}")
print()
print("=" * 60)
print("Demo completed successfully!")
print("=" * 60)
except Exception as e:
print(f"✗ Error occurred: {e}")
import traceback
traceback.print_exc()
return 1
return 0
if __name__ == "__main__":
exit(main())