FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PaddleSpeech/setup.py at develop · Algorithm-EAjks/PaddleSpeech · GitHub
Algorithm-EAjks
/
PaddleSpeech
Public
forked from
PaddlePaddle/PaddleSpeech
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PaddleSpeech
/
setup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
382 lines (325 loc) · 10.3 KB
Breadcrumbs
PaddleSpeech
/
setup.py
Copy path
File metadata and controls
382 lines (325 loc) · 10.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
contextlib
import
inspect
import
io
import
os
import
subprocess
as
sp
import
sys
from
pathlib
import
Path
from
setuptools
import
Command
from
setuptools
import
find_packages
from
setuptools
import
setup
from
setuptools
.
command
.
develop
import
develop
from
setuptools
.
command
.
install
import
install
from
setuptools
.
command
.
test
import
test
HERE
=
Path
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
VERSION
=
'0.0.0'
COMMITID
=
'none'
def
determine_python_version
():
"""
Determine the current python version. The function return a string such as '3.7'.
"""
python_version
=
f"
{
sys
.
version_info
.
major
}
.
{
sys
.
version_info
.
minor
}
"
return
python_version
def
determine_opencc_version
():
# get gcc version
gcc_version
=
None
try
:
output
=
sp
.
check_output
(
[
'gcc'
,
'--version'
],
stderr
=
sp
.
STDOUT
,
text
=
True
)
for
line
in
output
.
splitlines
():
if
"gcc"
in
line
:
gcc_version
=
line
.
split
()[
-
1
]
except
Exception
as
e
:
gcc_version
=
None
# determine opencc version
if
gcc_version
:
if
int
(
gcc_version
.
split
(
"."
)[
0
])
<=
9
:
return
"opencc==1.1.6"
# GCC<=9 need opencc==1.1.6
return
"opencc"
# default
def
determine_scipy_version
():
# get python version
python_version
=
determine_python_version
()
# determine scipy version
if
python_version
==
"3.8"
:
return
"scipy>=1.4.0, <=1.12.0"
# Python3.8 need scipy>=1.4.0, <=1.12.0
return
"scipy"
# default
def
determine_matplotlib_version
():
# get python version
python_version
=
determine_python_version
()
# determine matplotlib version
if
python_version
==
"3.8"
or
python_version
==
"3.9"
:
return
"matplotlib<=3.8.4"
# Python3.8/9 need matplotlib<=3.8.4
return
"matplotlib"
# default
base
=
[
"braceexpand"
,
"editdistance"
,
"g2p_en"
,
"g2pM"
,
"h5py"
,
"hyperpyyaml"
,
"inflect"
,
"jsonlines"
,
# paddleaudio align with librosa==0.8.1, which need numpy==1.23.x
"numpy==1.23.5"
,
"librosa==0.8.1"
,
determine_scipy_version
(),
# scipy or scipy>=1.4.0, <=1.12.0
"loguru"
,
determine_matplotlib_version
(),
# matplotlib or matplotlib<=3.8.4
"nara_wpe"
,
"onnxruntime>=1.11.0"
,
determine_opencc_version
(),
# opencc or opencc==1.1.6
"opencc-python-reimplemented"
,
"pandas"
,
"paddleaudio>=1.1.0"
,
"paddlenlp>=2.4.8"
,
"paddleslim>=2.3.4"
,
"ppdiffusers>=0.9.0"
,
"paddlespeech_feat"
,
"praatio>=6.0.0"
,
"prettytable"
,
"pydantic"
,
"pypinyin"
,
"pypinyin-dict"
,
"python-dateutil"
,
"pyworld>=0.2.12"
,
"pyyaml"
,
"resampy"
,
"sacrebleu"
,
"soundfile"
,
"textgrid"
,
"timer"
,
"ToJyutping"
,
"typeguard"
,
"webrtcvad"
,
"yacs>=0.1.8"
,
"zhon"
,
]
server
=
[
"pattern_singleton"
,
"websockets"
]
requirements
=
{
"install"
:
base
+
server
,
"develop"
: [
"ConfigArgParse"
,
"coverage"
,
"gpustat"
,
"paddlespeech_ctcdecoders"
,
"phkit"
,
"pypi-kenlm"
,
"snakeviz"
,
"sox"
,
"soxbindings"
,
"unidecode"
,
"yq"
,
"pre-commit"
,
]
}
def
check_call
(
cmd
:
str
,
shell
=
False
,
executable
=
None
):
try
:
sp
.
check_call
(
cmd
.
split
(),
shell
=
shell
,
executable
=
"/bin/bash"
if
shell
else
executable
)
except
sp
.
CalledProcessError
as
e
:
print
(
f"
{
__file__
}
:
{
inspect
.
currentframe
().
f_lineno
}
: CMD:
{
cmd
}
, Error:"
,
e
.
output
,
file
=
sys
.
stderr
)
raise
e
def
check_output
(
cmd
:
str
,
shell
=
False
):
try
:
out_bytes
=
sp
.
check_output
(
cmd
.
split
())
except
sp
.
CalledProcessError
as
e
:
out_bytes
=
e
.
output
# Output generated before error
code
=
e
.
returncode
# Return code
print
(
f"
{
__file__
}
:
{
inspect
.
currentframe
().
f_lineno
}
: CMD:
{
cmd
}
, Error:"
,
out_bytes
,
file
=
sys
.
stderr
)
return
out_bytes
.
strip
().
decode
(
'utf8'
)
@
contextlib
.
contextmanager
def
pushd
(
new_dir
):
old_dir
=
os
.
getcwd
()
os
.
chdir
(
new_dir
)
print
(
new_dir
)
yield
os
.
chdir
(
old_dir
)
print
(
old_dir
)
def
read
(
*
names
,
**
kwargs
):
with
io
.
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
*
names
),
encoding
=
kwargs
.
get
(
"encoding"
,
"utf8"
))
as
fp
:
return
fp
.
read
()
def
_remove
(
files
:
str
):
for
f
in
files
:
f
.
unlink
()
################################# Install ##################################
def
_post_install
(
install_lib_dir
):
# tools/make
tool_dir
=
HERE
/
"tools"
_remove
(
tool_dir
.
glob
(
"*.done"
))
with
pushd
(
tool_dir
):
check_call
(
"make"
)
print
(
"tools install."
)
# ctcdecoder
ctcdecoder_dir
=
HERE
/
'third_party/ctc_decoders'
with
pushd
(
ctcdecoder_dir
):
check_call
(
"bash -e setup.sh"
)
print
(
"ctcdecoder install."
)
class
DevelopCommand
(
develop
):
def
run
(
self
):
develop
.
run
(
self
)
# must after develop.run, or pkg install by shell will not see
self
.
execute
(
_post_install
, (
self
.
install_lib
, ),
msg
=
"Post Install..."
)
class
InstallCommand
(
install
):
def
run
(
self
):
install
.
run
(
self
)
class
TestCommand
(
test
):
def
finalize_options
(
self
):
test
.
finalize_options
(
self
)
self
.
test_args
=
[]
self
.
test_suite
=
True
def
run_tests
(
self
):
# Run nose ensuring that argv simulates running nosetests directly
import
nose
nose
.
run_exit
(
argv
=
[
'nosetests'
,
'-w'
,
'tests'
])
# cmd: python setup.py upload
class
UploadCommand
(
Command
):
description
=
"Build and publish the package."
user_options
=
[]
def
initialize_options
(
self
):
pass
def
finalize_options
(
self
):
pass
def
run
(
self
):
try
:
print
(
"Removing previous dist/ ..."
)
shutil
.
rmtree
(
str
(
HERE
/
"dist"
))
except
OSError
:
pass
print
(
"Building source distribution..."
)
sp
.
check_call
([
sys
.
executable
,
"setup.py"
,
"sdist"
])
print
(
"Uploading package to PyPi..."
)
sp
.
check_call
([
"twine"
,
"upload"
,
"dist/*"
])
sys
.
exit
()
################################# Version ##################################
def
write_version_py
(
filename
=
'paddlespeech/__init__.py'
):
import
paddlespeech
if
hasattr
(
paddlespeech
,
"__version__"
)
and
paddlespeech
.
__version__
==
VERSION
:
return
with
open
(
filename
,
"a"
)
as
f
:
out_str
=
f"
\n
__version__ = '
{
VERSION
}
'
\n
"
print
(
out_str
)
f
.
write
(
f"
\n
__version__ = '
{
VERSION
}
'
\n
"
)
COMMITID
=
check_output
(
"git rev-parse HEAD"
)
with
open
(
filename
,
'a'
)
as
f
:
out_str
=
f"
\n
__commit__ = '
{
COMMITID
}
'
\n
"
print
(
out_str
)
f
.
write
(
f"
\n
__commit__ = '
{
COMMITID
}
'
\n
"
)
print
(
f"
{
inspect
.
currentframe
().
f_code
.
co_name
}
done"
)
def
remove_version_py
(
filename
=
'paddlespeech/__init__.py'
):
with
open
(
filename
,
"r"
)
as
f
:
lines
=
f
.
readlines
()
with
open
(
filename
,
"w"
)
as
f
:
for
line
in
lines
:
if
"__version__"
in
line
or
"__commit__"
in
line
:
continue
f
.
write
(
line
)
print
(
f"
{
inspect
.
currentframe
().
f_code
.
co_name
}
done"
)
@
contextlib
.
contextmanager
def
version_info
():
write_version_py
()
yield
remove_version_py
()
################################# Steup ##################################
setup_info
=
dict
(
# Metadata
name
=
'paddlespeech'
,
version
=
VERSION
,
author
=
'PaddlePaddle Speech and Language Team'
,
author_email
=
'paddlesl@baidu.com'
,
url
=
'https://github.com/PaddlePaddle/PaddleSpeech'
,
license
=
'Apache 2.0'
,
description
=
'Speech tools and models based on Paddlepaddle'
,
long_description
=
read
(
"README.md"
),
long_description_content_type
=
"text/markdown"
,
keywords
=
[
"SSL"
"speech"
,
"asr"
,
"tts"
,
"speaker verfication"
,
"speech classfication"
,
"text frontend"
,
"MFA"
,
"paddlepaddle"
,
"paddleaudio"
,
"streaming asr"
,
"streaming tts"
,
"beam search"
,
"ctcdecoder"
,
"deepspeech2"
,
"wav2vec2"
,
"hubert"
,
"wavlm"
,
"transformer"
,
"conformer"
,
"fastspeech2"
,
"hifigan"
,
"gan vocoders"
,
],
python_requires
=
'>=3.7'
,
install_requires
=
requirements
[
"install"
],
extras_require
=
{
'develop'
:
requirements
[
"develop"
],
'doc'
: [
"sphinx"
,
"sphinx-rtd-theme"
,
"numpydoc"
,
"myst_parser"
,
"recommonmark>=0.5.0"
,
"sphinx-markdown-tables"
,
"sphinx-autobuild"
],
'test'
: [
'nose'
,
'torchaudio==0.10.2'
],
},
cmdclass
=
{
'develop'
:
DevelopCommand
,
'install'
:
InstallCommand
,
'upload'
:
UploadCommand
,
'test'
:
TestCommand
,
},
# Package info
packages
=
find_packages
(
include
=
[
'paddlespeech*'
],
exclude
=
[
'utils'
,
'third_party'
]),
zip_safe
=
True
,
classifiers
=
[
'Development Status :: 5 - Production/Stable'
,
'Intended Audience :: Developers'
,
'Intended Audience :: Science/Research'
,
'Topic :: Scientific/Engineering :: Artificial Intelligence'
,
'License :: OSI Approved :: Apache Software License'
,
'Programming Language :: Python'
,
'Programming Language :: Python :: 3'
,
'Programming Language :: Python :: 3.8'
,
'Programming Language :: Python :: 3.9'
,
'Programming Language :: Python :: 3.10'
,
],
entry_points
=
{
'console_scripts'
: [
'paddlespeech=paddlespeech.cli.entry:_execute'
,
'paddlespeech_server=paddlespeech.server.entry:server_execute'
,
'paddlespeech_client=paddlespeech.server.entry:client_execute'
]
})
with
version_info
():
setup
(
**
setup_info
,
include_package_data
=
True
)
Back
|
FazBrowse Home
|
New Git URL