Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API reference for LPC? #8

Open
akhil2495 opened this issue Nov 22, 2018 · 1 comment
Open

API reference for LPC? #8

akhil2495 opened this issue Nov 22, 2018 · 1 comment

Comments

@akhil2495
Copy link

Can parselmouth be used to extract linear predictive coding coefficients?

@YannickJadoul
Copy link
Owner

Yes, but there's indeed no API reference for this, because there is no Python API, yet.

Until I add this (or someone else does; help welcome ;-) ), you can go through parselmouth.praat.call:

>>> import parselmouth
>>> s = parselmouth.Sound("the_north_wind_and_the_sun.wav")
>>> lpc = parselmouth.praat.call(s, "To LPC (autocorrelation)", 16, 0.025, 0.005, 50.0)
>>> lpc
<parselmouth.Data object at 0x7f4f3f5d3c00>
>>> lpc.class_name
'LPC'
>>> print(lpc)
Object type: LPC
Object name: untitled
Date: Thu Nov 22 11:38:48 2018

Time domain: 0 to 1.283265306122449 (s).
Prediction order: 16
Number of frames: 247
Time step: 0.005 (s).
First frame at: 0.026632653061224473 (s).

As you can see, the Python type of lpc is parselmouth.Data (so it does not have a lot of methods), but the actual underlying Praat type is "LPC", which means you can use it in further calls to parselmouth.praat.call until you get a more useful object or the values you're interested in. For example, you could:

>>> parselmouth.praat.call(lpc, "Get number of coefficients", 1)
16

Or to get all raw values (consult the Praat documentation to see what these actually mean!), you could:

>>> lpc_matrix = parselmouth.praat.call(lpc, "Down to Matrix (lpc)")
>>> lpc_matrix
<parselmouth.Matrix object at 0x7f4f3f5eac00>
>>> lpc_matrix.values
array([[ 0.12599566,  0.12089129,  0.1061873 , ..., -1.19781365,
        -1.14358651, -1.1659433 ],
       [ 0.51795006,  0.46722564,  0.51150008, ...,  1.14546318,
         1.09264874,  1.14384542],
       [-0.01884895,  0.02674646,  0.04591352, ..., -1.38964444,
        -1.42701829, -1.50292197],
       ...,
       [-0.01957717, -0.00318544, -0.09061003, ...,  0.46313035,
         0.41949584,  0.54231048],
       [-0.06745527, -0.0395186 , -0.03539812, ..., -0.2470586 ,
        -0.23618874, -0.33601743],
       [-0.01429427,  0.00990911, -0.02896412, ...,  0.05589769,
         0.06509704,  0.10742232]])
>>> lpc_matrix.values.shape
(16, 247)

I'll have a look how much work it would be to port LPC to the Python API, and see if I can maybe find some time within the next few months, so you can leave this issue open for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants