Skip to content

Commit f1d8d2c

Browse files
committed
adding preemphasizing and resolving packaging issues
1 parent c7b0836 commit f1d8d2c

8 files changed

Lines changed: 50 additions & 35 deletions

File tree

docs/source/content/features.rst~

Lines changed: 0 additions & 32 deletions
This file was deleted.

docs/source/content/preprocessing.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Preprocessing
88
.. automodule:: speechpy.processing
99
.. currentmodule:: speechpy.processing
1010

11+
:hidden:`Pre-emphasizing`
12+
~~~~~~~~~~~~~~~~~~~~~~~~~
13+
.. autofunction:: speechpy.processing.preemphase
14+
1115
:hidden:`Stacking`
1216
~~~~~~~~~~~~~~~~~~
1317
.. autofunction:: speechpy.processing.stack_frames

docs/source/content/preprocessing.rst~

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@ Preprocessing
1010

1111
:hidden:`Stacking`
1212
~~~~~~~~~~~~~~~~~~
13-
1413
.. autofunction:: speechpy.processing.stack_frames
1514

15+
:hidden:`Pre-emphasizing`
16+
~~~~~~~~~~~~~~~~~~~~~~~~~
17+
.. autofunction:: speechpy.processing.preemphase
18+
19+
:hidden:`FFT Spectrum`
20+
~~~~~~~~~~~~~~~~~~~~~~
1621
.. autofunction:: speechpy.processing.fft_spectrum
1722

23+
:hidden:`Power Spectrum`
24+
~~~~~~~~~~~~~~~~~~~~~~~~
1825
.. autofunction:: speechpy.processing.power_spectrum
1926

27+
:hidden:`Power Spectrum Log`
28+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2029
.. autofunction:: speechpy.processing.log_power_spectrum

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22

33
setup(name='speechpy',
4-
version='1.3.5',
4+
version='1.4.1',
55
description='The python package for extracting speech features.',
66
author='Amirsina Torfi',
77
author_email='[email protected]',

setup.py~

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(name='speechpy',
4+
version='1.3.6',
5+
description='The python package for extracting speech features.',
6+
author='Amirsina Torfi',
7+
author_email='[email protected]',
8+
url='https://github.com/astorfi/speech_feature_extraction',
9+
packages=find_packages(exclude=('tests', 'docs')),
10+
include_package_data=True,
11+
install_requires=[
12+
'scipy',
13+
'numpy',
14+
],
15+
zip_safe=False)

speechpy/processing.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ def round_half_up(number):
88
return int(decimal.Decimal(number).quantize(decimal.Decimal('1'), rounding=decimal.ROUND_HALF_UP))
99

1010

11+
def preemphase(signal, cof=0.98):
12+
"""preemphasising on the signal.
13+
:param signal: The input signal.
14+
:param coeff: The preemphasising coefficient. 0 equals to no filtering.
15+
:returns: the pre-emphasized signal.
16+
"""
17+
18+
rolled_signal = np.roll(signal, shift=1)
19+
return signal - cof * rolled_signal
20+
1121
def stack_frames(sig, sampling_frequency, frame_length=0.020, frame_stride=0.020, Filter=lambda x: np.ones((x,)),
1222
zero_padding=True):
1323
"""Frame a signal into overlapping frames.
@@ -221,14 +231,16 @@ def cmvnw(vec, win_size=301, variance_normalization=False):
221231

222232
return output
223233

234+
235+
224236
# def resample_Fn(wave, fs, f_new=16000):
225237
# """This function resample the data to arbitrary frequency
226238
# :param fs: Frequency of the sound file.
227239
# :param wave: The sound file itself.
228240
# :returns:
229241
# f_new: The new frequency.
230242
# signal_new: The new signal samples at new frequency.
231-
243+
#
232244
# dependency: from scikits.samplerate import resample
233245
# """
234246
#

tests/test_local.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
fs, signal = wav.read(file_name)
1313
signal = signal[:,0]
1414

15+
# Example of pre-emphasizing.
16+
signal_preemphasized = speechpy.processing.preemphase(signal, cof=0.98)
17+
1518
# Example of staching frames
1619
frames = speechpy.processing.stack_frames(signal, sampling_frequency=fs, frame_length=0.020, frame_stride=0.01, Filter=lambda x: np.ones((x,)),
1720
zero_padding=True)

tests/test_package.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
fs, signal = wav.read(file_name)
88
signal = signal[:,0]
99

10+
# Example of pre-emphasizing.
11+
signal_preemphasized = speechpy.processing.preemphase(signal, cof=0.98)
12+
1013
# Example of staching frames
1114
frames = speechpy.processing.stack_frames(signal, sampling_frequency=fs, frame_length=0.020, frame_stride=0.01, Filter=lambda x: np.ones((x,)),
1215
zero_padding=True)
@@ -32,3 +35,4 @@
3235

3336

3437

38+

0 commit comments

Comments
 (0)