forked from haguvenir/Turkish_TTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextSynthesis.cpp
More file actions
89 lines (66 loc) · 2.19 KB
/
TextSynthesis.cpp
File metadata and controls
89 lines (66 loc) · 2.19 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "TextSynthesis.h"
void GetPhones(TCHAR * word, TCHAR phones[][MAX_PHONE_LENGTH], int* count)
{
int wordLength = _tcsclen(word);
int phoneCount = 0;
int current, previousPhoneEnd;
current = previousPhoneEnd = 0;
memset(phones, 0, MAX_PHONE_LENGTH * MAX_PHONE_COUNT);
for(int i = 0; i< wordLength; i+= _tclen(word+i) ) {
current = i;
if(current == (wordLength -1) ) {
if( (current - previousPhoneEnd+1) > 3) {
if(!IsVowel(word[previousPhoneEnd+2]) && !IsVowel(word[previousPhoneEnd+3])) {
memcpy(&(phones[phoneCount]), &word[previousPhoneEnd],3);
previousPhoneEnd+=3;
}
else {
memcpy(&(phones[phoneCount]), &word[previousPhoneEnd],2);
previousPhoneEnd+=2;
}
phoneCount++;
}
memcpy(&(phones[phoneCount]), &word[previousPhoneEnd],current - previousPhoneEnd+1);
phoneCount++;
break;
}
else if(IsVowel(word[i])) {
if(i==0) {
;
}
else if( IsVowel(word[i+1])) {
memcpy(&phones[phoneCount], &word[previousPhoneEnd], current - previousPhoneEnd+1);
previousPhoneEnd = current+1;
phoneCount++;
}
else if( IsVowel(word[i-1])) {
;
}
//if both sides are vowel
else if(!IsVowel(word[i+1]) ) {
if( (current - previousPhoneEnd+1) > 3) {
if(!IsVowel(word[previousPhoneEnd+2]) && !IsVowel(word[previousPhoneEnd+3])) {
memcpy(&(phones[phoneCount]), &word[previousPhoneEnd],3);
previousPhoneEnd+=3;
}
else {
memcpy(&(phones[phoneCount]), &word[previousPhoneEnd],2);
previousPhoneEnd+=2;
}
phoneCount++;
}
memcpy(&phones[phoneCount], &word[previousPhoneEnd], current - previousPhoneEnd+1);
previousPhoneEnd = current;
phoneCount++;
}
}
}
*count = phoneCount;
}
int IsVowel(TCHAR ch) {
TCHAR vowels[] = {'a', 'â', 'e', 'ý' , 'î', 'i', 'o', 'ö', 'u', 'û', 'ü'};
for (int i =0; i< (int)_tcsclen(vowels); i+= (int)_tclen(vowels) ) {
if(vowels[i] == ch) return 1;
}
return 0;
}