-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
71 lines (62 loc) · 2.49 KB
/
main.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
from os import listdir
import os
from random import choice , sample
import random
#from siri import voices as siri_voices
#from azure_tts import voices as azure_voices
import siri
import azure_tts
from baseClasses import genders
from requests.exceptions import ConnectionError
siri_voices = siri.voices
azure_voices = azure_tts.voices
combinedVoices = dict()
def sendAlert(title:str,comment:str):
alert_command = (f"osascript -e \'display alert \"{title}\" message \"{comment}\"\'")
os.system(alert_command)
for country in siri_voices.keys() :
for gender in siri_voices[country].keys():
if(country not in combinedVoices.keys()):
combinedVoices[country] = dict()
if(gender not in combinedVoices[country].keys()):
combinedVoices[country][gender] = []
for voice in siri_voices[country][gender]:
combinedVoices[country][gender].append(
{
"name":voice,
"engine":"siri"
}
)
for country in azure_voices.keys() :
for gender in azure_voices[country].keys():
if(country not in combinedVoices.keys()):
combinedVoices[country] = dict()
if(gender not in combinedVoices[country].keys()):
combinedVoices[country][gender] = []
for voice in azure_voices[country][gender]:
combinedVoices[country][gender].append(
{
"name":voice,
"engine":"azure"
}
)
#pprint(combinedVoices)
words = open("./finalizedWordList.txt",'r').read().split("\n")
countries = combinedVoices.keys()
word_count = len(words)
START_FROM = len(listdir("dataset/"))#0
sendAlert("Starting datasysnthesis","Ensure stable internet connection")
try:
for i, word in enumerate(words[START_FROM:]):
print("Progress:",100*(i+START_FROM)/word_count)
randomlyChoosenCountries:list = sample(countries,5)
for country in randomlyChoosenCountries :
gender = choice([genders.male,genders.female])
voice = choice(combinedVoices[country][gender])
if(voice["engine"]=="siri"):
siri.getAudioSample(word,voice["name"])
else: #if not siri then azure
azure_tts.getAudioSample(word,voice["name"])
sendAlert("Dataset Synthesis Completed","Dont run code again")
except ConnectionError :
sendAlert("Siameses dataset synthesis terminated","Unable to communicate to server , please run again")