-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
203 lines (184 loc) · 6.22 KB
/
build.gradle
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import marytts.modules.phonemiser.AllophoneSet
plugins {
id 'de.dfki.mary.lexicon-compiler' version '0.3.0'
id 'maven-publish'
id 'signing'
}
group 'de.dfki.mary'
version '0.2.0-SNAPSHOT'
description 'US English lexicon for MaryTTS'
ext {
url = 'https://github.com/marytts/marytts-lexicon-en_US-cmudict'
isReleaseVersion = !version.endsWith("SNAPSHOT")
}
repositories {
exclusiveContent {
forRepositories(
ivy {
url 'http://festvox.org/packed/festival/2.4/'
allowInsecureProtocol = true
patternLayout {
artifact '[module]_[classifier].[ext]'
}
metadataSources {
artifact()
}
},
ivy {
url 'https://www.cstr.ed.ac.uk/downloads/festival/2.4/'
patternLayout {
artifact '[module]_[classifier].[ext]'
}
metadataSources {
artifact()
}
}
)
filter {
includeModule 'org.festvox', 'festlex'
}
}
}
configurations {
cmudict
}
dependencies {
cmudict group: 'org.festvox', name: 'festlex', version: '0.4', classifier: 'CMU', ext: 'tar.gz'
}
def unpackCmuDictTask = tasks.register('unpackCmuDict') {
def config = configurations.named('cmudict')
ext.destDir = objects.directoryProperty()
.convention(layout.buildDirectory.dir('cmudict'))
inputs.property 'config', config
outputs.dir destDir
doLast {
copy {
into destDir
from config
filesMatching '*.tar.gz', { tarDetails ->
copy {
into destDir
from tarTree(tarDetails.file)
include '**/cmudict-0.4.scm',
'**/cmudict_extensions.scm',
'**/COPYING'
eachFile {
it.path = it.name
}
}
tarDetails.exclude()
}
}
}
}
def allophoneSetFile = objects.fileProperty()
.convention(layout.projectDirectory.dir('modules/en/us/lexicon').file('allophones.en_US.xml'))
def processCmuDictTask = tasks.register('processCmuDict') {
def srcDir = objects.directoryProperty()
.convention(unpackCmuDictTask.get().destDir)
def mappingFile = objects.fileProperty()
.convention(layout.projectDirectory.dir('modules/en/synthesis').file('sampa2mrpa_en.map'))
ext.destFile = objects.fileProperty()
.convention(layout.buildDirectory.file('cmudict.txt'))
inputs.dir srcDir
inputs.file mappingFile
inputs.file allophoneSetFile
outputs.file destFile
doLast {
def phoneMapping = [:]
mappingFile.get().asFile.eachLine { line ->
(line =~ /(.+)<->(.+)/).each { match, sampa, mrpa ->
phoneMapping[mrpa] = sampa
}
}
def stressMapping = [
'1': "'",
'2': ','
]
def allophoneSet = AllophoneSet.getAllophoneSet(allophoneSetFile.get().asFile.path)
destFile.get().asFile.withWriter { dest ->
fileTree(srcDir).include('*.scm').each { scmFile ->
scmFile.eachLine('UTF-8') { line ->
(line =~ /\("(\w+)" (\w+) \((.+)\)\)/).each { match, lemma, pos, transcription ->
def transcriptionMapped = transcription.replaceAll(~/\b(\S+?)([0-2])?\b/, { all, phone, stress ->
def mappedPhone = phoneMapping[phone] ?: phone
def mappedStress = stressMapping[stress] ?: ''
mappedStress + mappedPhone
})
def transcriptionSyllabified = allophoneSet.syllabify(transcriptionMapped)
def transcriptionNoSpaces = transcriptionSyllabified.replaceAll(' ', '')
dest.writeLine("$lemma $transcriptionNoSpaces")
}
}
}
}
}
}
tasks.named('compileLexicon').configure {
allophonesFile.set allophoneSetFile
lexiconFile.set processCmuDictTask.get().destFile
}
tasks.named('processResources').configure {
from unpackCmuDictTask, {
include 'COPYING'
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = project.name
description = project.description
url = project.url
licenses {
license {
name = 'GNU Lesser General Public License v3.0 only'
url = 'https://spdx.org/licenses/LGPL-3.0-only.html'
}
}
developers {
developer {
name = 'Ingmar Steiner'
id = 'psibre'
}
developer {
name = 'Marc Schröder'
id = 'marc1s'
}
developer {
name = 'Marcela Charfuelan'
id = 'marcelach1'
}
}
scm {
connection = "scm:git:${project.url}.git"
developerConnection = "scm:git:ssh://git@github.com:marytts/${project.name}.git"
url = project.url
}
}
}
}
repositories {
maven {
name 'OSSRH'
url isReleaseVersion ? 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
: 'https://oss.sonatype.org/content/repositories/snapshots'
credentials(PasswordCredentials)
}
}
}
signing {
required { isReleaseVersion }
sign publishing.publications.mavenJava
}
tasks.withType(Sign).configureEach {
onlyIf { isReleaseVersion }
}