-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_local_voices.py
More file actions
56 lines (45 loc) · 1.78 KB
/
Copy pathgenerate_local_voices.py
File metadata and controls
56 lines (45 loc) · 1.78 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
from tts_wrapper import AVSynthTTS, AVSynthClient, eSpeakTTS, eSpeakClient
import json
import os
import platform
def generate_avsynth_voices():
"""Generate JSON file for AVSynth voices (Mac only)"""
if platform.system() != 'Darwin':
print("AVSynth is only available on macOS")
return
try:
client = AVSynthClient()
tts = AVSynthTTS(client)
voices = tts.get_voices()
# Ensure the tts-data directory exists
os.makedirs('./tts-data', exist_ok=True)
# Write to JSON file
with open('./tts-data/avsynth.json', 'w', encoding='utf-8') as f:
json.dump(voices, f, indent=2, ensure_ascii=False)
print(f"Generated avsynth.json with {len(voices)} voices")
except Exception as e:
print(f"Error generating AVSynth voices: {e}")
def generate_espeak_voices():
"""Generate JSON file for eSpeak voices"""
try:
client = eSpeakClient()
tts = eSpeakTTS(client)
voices = tts.get_voices()
# Ensure the tts-data directory exists
os.makedirs('./tts-data', exist_ok=True)
# Write to JSON file
with open('./tts-data/espeak.json', 'w', encoding='utf-8') as f:
json.dump(voices, f, indent=2, ensure_ascii=False)
print(f"Generated espeak.json with {len(voices)} voices")
except Exception as e:
print(f"Error generating eSpeak voices: {e}")
if __name__ == "__main__":
print("Generating voice JSON files...")
# Generate AVSynth voices if on Mac
if platform.system() == 'Darwin':
print("Generating AVSynth voices...")
generate_avsynth_voices()
# Generate eSpeak voices
print("Generating eSpeak voices...")
generate_espeak_voices()
print("Done!")