Skip to content

Commit 73b4c36

Browse files
working
1 parent e06bdc6 commit 73b4c36

File tree

3 files changed

+76
-50
lines changed

3 files changed

+76
-50
lines changed

synthme.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
if __name__ == "__main__":
1111
# message = input("Message: ")
12-
message = "को"
13-
# t = "भेजना चाहते हैं हिंदी में मैसेज लेकिन नहीं"
14-
# for i in t:
15-
# print(i)
16-
# ज़ू
12+
# message = "को"
13+
message = "मैं सार्थक हूँ"
14+
15+
for i in message:
16+
print(i)
17+
1718

1819

1920
tts.text_to_speech(message, debug=True, use_pronunciation_dict=True)

synthme/convertphonemes.py

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ def phoneme_scan(word):
3737
# while re.search("[a-zA-Z.,;!?]", word):
3838
while re.search("[अ-ॐ.,;!?]", word):
3939

40-
word = replace_with_phoneme(word, r'iew', (phonemes.CONS_Y, phonemes.VOWEL_OO,phonemes.CONS_W))
40+
# word = replace_with_phoneme(word, r'iew', (phonemes.CONS_Y, phonemes.VOWEL_OO,phonemes.CONS_W))
4141

42-
word = replace_with_phoneme(word, r'oo', (phonemes.VOWEL_OO,))
43-
word = replace_with_phoneme(word, r'ou', (phonemes.VOWEL_OO,))
44-
word = replace_with_phoneme(word, r'ea', (phonemes.VOWEL_II,))
45-
word = replace_with_phoneme(word, r'ee', (phonemes.VOWEL_II,))
46-
47-
word = replace_with_phoneme(word, r'gg', (phonemes.CONS_J,))
48-
word = replace_with_phoneme(word, r'dd', (phonemes.CONS_D,))
49-
word = replace_with_phoneme(word, r'ph', (phonemes.CONS_F,))
50-
word = replace_with_phoneme(word, r'll', (phonemes.CONS_L,))
51-
word = replace_with_phoneme(word, r'ss', (phonemes.CONS_S,))
52-
word = replace_with_phoneme(word, r'nn', (phonemes.CONS_N,))
53-
word = replace_with_phoneme(word, r'ch', (phonemes.CONS_CH,))
54-
word = replace_with_phoneme(word, r'sh', (phonemes.CONS_SH,))
55-
word = replace_with_phoneme(word, r'th', (phonemes.CONS_TH,))
56-
word = replace_with_phoneme(word, r'ck', (phonemes.CONS_K,))
42+
# word = replace_with_phoneme(word, r'oo', (phonemes.VOWEL_OO,))
43+
# word = replace_with_phoneme(word, r'ou', (phonemes.VOWEL_OO,))
44+
# word = replace_with_phoneme(word, r'ea', (phonemes.VOWEL_II,))
45+
# word = replace_with_phoneme(word, r'ee', (phonemes.VOWEL_II,))
46+
47+
# word = replace_with_phoneme(word, r'gg', (phonemes.CONS_J,))
48+
# word = replace_with_phoneme(word, r'dd', (phonemes.CONS_D,))
49+
# word = replace_with_phoneme(word, r'ph', (phonemes.CONS_F,))
50+
# word = replace_with_phoneme(word, r'll', (phonemes.CONS_L,))
51+
# word = replace_with_phoneme(word, r'ss', (phonemes.CONS_S,))
52+
# word = replace_with_phoneme(word, r'nn', (phonemes.CONS_N,))
53+
# word = replace_with_phoneme(word, r'ch', (phonemes.CONS_CH,))
54+
# word = replace_with_phoneme(word, r'sh', (phonemes.CONS_SH,))
55+
# word = replace_with_phoneme(word, r'th', (phonemes.CONS_TH,))
56+
# word = replace_with_phoneme(word, r'ck', (phonemes.CONS_K,))
5757

5858
# # Default letters
5959
# क
@@ -94,9 +94,34 @@ def phoneme_scan(word):
9494
# स
9595
# ह
9696

97+
word = replace_with_phoneme(word, "अ", (phonemes.VOWEL_U,))
9798
word = replace_with_phoneme(word, "आ", (phonemes.VOWEL_A,))
9899
word = replace_with_phoneme(word, "ा", (phonemes.VOWEL_A,))
99100

101+
word = replace_with_phoneme(word, "इ", (phonemes.VOWEL_I,))
102+
word = replace_with_phoneme(word, "ि", (phonemes.VOWEL_I,))
103+
word = replace_with_phoneme(word, "ई", (phonemes.VOWEL_II,))
104+
word = replace_with_phoneme(word, "ी", (phonemes.VOWEL_II,))
105+
106+
word = replace_with_phoneme(word, "उ", (phonemes.VOWEL_PU,))
107+
word = replace_with_phoneme(word, "ु", (phonemes.VOWEL_PU,))
108+
word = replace_with_phoneme(word, "ऊ", (phonemes.VOWEL_OO,))
109+
word = replace_with_phoneme(word, "ू", (phonemes.VOWEL_OO,))
110+
word = replace_with_phoneme(word, "ृ", (phonemes.CONS_R,))
111+
112+
word = replace_with_phoneme(word, "ए", (phonemes.VOWEL_AE,))
113+
word = replace_with_phoneme(word, "े", (phonemes.VOWEL_AE,))
114+
word = replace_with_phoneme(word, "ॆ", (phonemes.VOWEL_AE,))
115+
word = replace_with_phoneme(word, "ऐ", (phonemes.VOWEL_E,))
116+
word = replace_with_phoneme(word, "ै", (phonemes.VOWEL_E,))
117+
118+
word = replace_with_phoneme(word, "ओ", (phonemes.VOWEL_OH,))
119+
word = replace_with_phoneme(word, "ऒ", (phonemes.VOWEL_OH,))
120+
word = replace_with_phoneme(word, "ो", (phonemes.VOWEL_OH,))
121+
word = replace_with_phoneme(word, "औ", (phonemes.VOWEL_CA,))
122+
word = replace_with_phoneme(word, "ौ", (phonemes.VOWEL_CA,))
123+
word = replace_with_phoneme(word, "ऑ", (phonemes.VOWEL_CA,))
124+
100125
word = replace_with_phoneme(word, "क", (phonemes.CONS_K,))
101126
word = replace_with_phoneme(word, "ख", (phonemes.CONS_K,))
102127
word = replace_with_phoneme(word, "ग", (phonemes.CONS_G,))
@@ -107,45 +132,43 @@ def phoneme_scan(word):
107132
word = replace_with_phoneme(word, "छ", (phonemes.CONS_JJ,))
108133
word = replace_with_phoneme(word, "ज", (phonemes.CONS_J,))
109134
word = replace_with_phoneme(word, "झ", (phonemes.CONS_JJ,))
135+
word = replace_with_phoneme(word, "ञ", (phonemes.CONS_N,))
110136

111137

112138
word = replace_with_phoneme(word, "ट", (phonemes.CONS_T,))
113139
word = replace_with_phoneme(word, "ठ", (phonemes.CONS_TH,))
114-
word = replace_with_phoneme(word, "द", (phonemes.CONS_TH2,))
115-
word = replace_with_phoneme(word, "ध", (phonemes.CONS_TH,))
116-
117-
118140
word = replace_with_phoneme(word, "ड", (phonemes.CONS_D,))
119141
word = replace_with_phoneme(word, "ढ", (phonemes.CONS_D,))
120-
word = replace_with_phoneme(word, "", (phonemes.CONS_B,))
142+
word = replace_with_phoneme(word, "", (phonemes.CONS_N,))
121143

122-
word = replace_with_phoneme(word, "ऐ", (phonemes.VOWEL_E,))
123-
word = replace_with_phoneme(word, "ै", (phonemes.VOWEL_E,))
144+
word = replace_with_phoneme(word, "त", (phonemes.CONS_TH,))
145+
word = replace_with_phoneme(word, "थ", (phonemes.CONS_TH,))
146+
word = replace_with_phoneme(word, "ध", (phonemes.CONS_TH,))
147+
word = replace_with_phoneme(word, "द", (phonemes.CONS_TH2,))
148+
word = replace_with_phoneme(word, "न", (phonemes.CONS_N,))
124149

150+
word = replace_with_phoneme(word, "प", (phonemes.CONS_P,))
125151
word = replace_with_phoneme(word, "फ", (phonemes.CONS_F,))
126-
word = replace_with_phoneme(word, "ह", (phonemes.CONS_H,))
127-
word = replace_with_phoneme(word, "इ", (phonemes.VOWEL_I,))
128-
word = replace_with_phoneme(word, "ि", (phonemes.VOWEL_I,))
152+
word = replace_with_phoneme(word, "ब", (phonemes.CONS_B,))
153+
word = replace_with_phoneme(word, "भ", (phonemes.CONS_P,))
154+
word = replace_with_phoneme(word, "म", (phonemes.CONS_M,))
155+
word = replace_with_phoneme(word, "य", (phonemes.CONS_Y,))
129156

157+
word = replace_with_phoneme(word, "र", (phonemes.CONS_R,))
130158
word = replace_with_phoneme(word, "ल", (phonemes.CONS_L,))
131-
word = replace_with_phoneme(word, "म", (phonemes.CONS_M,))
132-
word = replace_with_phoneme(word, "न", (phonemes.CONS_N,))
133-
word = replace_with_phoneme(word, "ञ", (phonemes.CONS_N,))
134-
word = replace_with_phoneme(word, "ण", (phonemes.CONS_N,))
159+
word = replace_with_phoneme(word, "व", (phonemes.CONS_V,))
160+
word = replace_with_phoneme(word, "श", (phonemes.CONS_SH,))
161+
word = replace_with_phoneme(word, "ष", (phonemes.CONS_SH,))
162+
word = replace_with_phoneme(word, "स", (phonemes.CONS_S,))
163+
word = replace_with_phoneme(word, "ह", (phonemes.CONS_H,))
164+
165+
word = replace_with_phoneme(word, "ज़", (phonemes.CONS_Z,))
166+
135167

136-
word = replace_with_phoneme(word, "ो", (phonemes.VOWEL_OH,))
137-
word = replace_with_phoneme(word, "प", (phonemes.CONS_P,))
138-
word = replace_with_phoneme(word, "भ", (phonemes.CONS_P,))
139168
# word = replace_with_phoneme(word, "q", (phonemes.CONS_K,))
140-
word = replace_with_phoneme(word, "र", (phonemes.CONS_R,))
141169

142-
word = replace_with_phoneme(word, "स", (phonemes.CONS_S,))
143-
word = replace_with_phoneme(word, "अ", (phonemes.VOWEL_U,))
144-
word = replace_with_phoneme(word, "व", (phonemes.CONS_V,))
145170
# word = replace_with_phoneme(word, "w", (phonemes.CONS_W,))
146171
# word = replace_with_phoneme(word, "x", (phonemes.CONS_K, phonemes.CONS_S))
147-
word = replace_with_phoneme(word, "य", (phonemes.CONS_Y,))
148-
word = replace_with_phoneme(word, "ज़", (phonemes.CONS_Z,))
149172
word = replace_with_phoneme(word, ".", (phonemes.PUNC_PERIOD,))
150173
word = replace_with_phoneme(word, ",", (phonemes.PUNC_COMMA,))
151174
word = replace_with_phoneme(word, ";", (phonemes.PUNC_COMMA,))

synthme/phonemes.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
VOWEL_UU = 5 # turn, learn
1010
VOWEL_I = 6 # hit, sitting इ
1111
VOWEL_II = 7 # see, heat ई
12-
VOWEL_O = 8 # hot, rock
12+
VOWEL_O = 8 # hot, rock
1313
VOWEL_CA = 9 # call, four औ
1414
VOWEL_PU = 10 # put, could उ
1515
VOWEL_OO = 11 # blue, food ऊ
1616
VOWEL_AI = 12 # five, eye
1717
VOWEL_AU = 13 # now, out
1818
VOWEL_EI = 14 # say, eight
19-
VOWEL_OH = 15 # go, home
19+
VOWEL_OH = 15 # go, home
2020
VOWEL_OI = 16 # boy, join
2121
VOWEL_ER = 17 # where, air
2222
VOWEL_IE = 18 # near, here
@@ -32,6 +32,7 @@
3232
CONS_L = 27 # leg, litte ल
3333

3434
CONS_M = 28 # man, lemon म
35+
# todo
3536
CONS_N = 29 # no, ten न ञ ण
3637
CONS_NG = 30 # sing, finger ं
3738
CONS_P = 31 # pet, map प भ
@@ -49,7 +50,8 @@
4950
CONS_J = 43 # just, large ज
5051

5152
PUNC_PERIOD = 44 # period (long pause) 0.5
52-
PUNC_COMMA = 45 # comma (short pause) 0.3
53-
PUNC_QUESTION = 46 # question 0.5
54-
PUNC_EXCLAIM = 47 # exclamation 0.5
55-
PAUSE_WORD = 48 # very short pause 0.2
53+
PUNC_COMMA = 44 # comma (short pause) 0.3
54+
PUNC_QUESTION = 44 # question 0.5
55+
PUNC_EXCLAIM = 44 # exclamation 0.5
56+
# to do
57+
PAUSE_WORD = 44 # very short pause 0.2

0 commit comments

Comments
 (0)