Some tools function
Project description
Guang
Scientific calculation of universal function library
Requirements
Python 3
CUDA >= 10.0
PyTorch >= 1.0
Tensorflow >= 1.12.0
opencv-python
pydub
librosa
pyworld
soundfile
pypinyin
pomegranate
python-Levenshtein
Installation
pip install guang
Nightly Build
pip install git+https://github.com/beidongjiedeguang/guang
Examples
-
Convert audio in .mp3/ .wav format to (sample rate=16k, single channel) .wav format
from guang.Voice.convert import cvt2wav cvt2wav(orig_path, target_path, sr=16000) # Multi-process from guang.Voice.convert import multi_cvt2wav multi_cvt2wav(PATH1, PATH2,sr=16000, n_cpu=None)
-
Use
dict_dotable
to convert a dictionary to dot-able dictionary:from guang.Utils.toolsFunc import dict_dotable a = {'a':{'b':1}} a = dict_dotable(a) print(a.a.b) >> 1
-
Use
probar
to display current progressfrom guang.Utils.toolsFunc import probar for idx, x in probar(range(10)): time.sleep(0.8) >> 100.00% 0'7.3"|0'7.3" Expect: 12-2 23:59:8
-
@broadcast
broadcast a non-broadcast function.from guang.Utils.toolsFunc import broadcast @broadcast def f(x): # A function that can map only a single element if x==1 or x==0: return x else: return f(x-1)+f(x-2) >> f([2,4,10]) >> array([1, 3, 832040], dtype=object)
-
txt2ph
Convert Chinese characters to phoneme.from guang.Voice.txt2pinyin import txt2ph txt2ph('你好,我是光') >> [('n', 'i3'), ('h', 'ao3'), ('sp1',), ('uo3',), ('sh', 'ii4'), ('g', 'uang1')]
-
reduce_from_duration
Remove files with duration less thanleast_time
seconds. Note that this function does not work in the interactive interpreter because it usesmultiprocessing.pool.Pool
from guang.Voice.reduce import reduce_from_duration reduced_list = reduce_from_duration(path_list, least_time=2) print(len(path_list), len(reduced_list)) >> (6889, 6714)
-
Find silence part of a sound file:
find_no_silence
from guang.Voice.reduce import find_no_silence start, end, arg_start, arg_end = find_no_silence(filename)
-
Download wechat files.
from guang.wechat.Utils.download import downloads downloads(nickName='caloi', fileType='mp3', d_t=60)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
guang-0.0.7.6.8.tar.gz
(16.8 kB
view hashes)
Built Distribution
guang-0.0.7.6.8-py3-none-any.whl
(36.0 kB
view hashes)
Close
Hashes for guang-0.0.7.6.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 367970736bf571062cdcc10616439ba22dba16e3066f1df6986344095432ab65 |
|
MD5 | 671f25a0906d3c928fc497fc00020a58 |
|
BLAKE2b-256 | 5cadaf9c21b5ad2e33722456142adfa509520ee35b38d7e0fedc0ba501adad28 |