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

change Audiosegment to ndarray for librosa to add effect #289

Closed
bzvew opened this issue Jun 12, 2018 · 6 comments · Fixed by #470
Closed

change Audiosegment to ndarray for librosa to add effect #289

bzvew opened this issue Jun 12, 2018 · 6 comments · Fixed by #470

Comments

@bzvew
Copy link

bzvew commented Jun 12, 2018

I wonder how to change Audiosegment to float32 ndarray for librosa to manipulate.

@jiaaro
Copy link
Owner

jiaaro commented Jun 14, 2018

Have you tried using ‘AudioSegment(…).get_array_of_samples()`?

@AbbyYangbb
Copy link

AbbyYangbb commented Jul 27, 2018

You can get "array.array"object by using AudioSegment(…).get_array_of_samples(), for example
,
ar = chunk.get_array_of_samples()

and if you want to get numpy.ndarray, try:
import numpy as np
ar = np.array(ar)

@zhenql
Copy link

zhenql commented Jul 18, 2019

You can get "array.array"object by using AudioSegment(…).get_array_of_samples(), for example
,
ar = chunk.get_array_of_samples()

and if you want to get numpy.ndarray, try:
import numpy as np
ar = np.array(ar)

the type of data x is int and |x| may more than 1, but the type of librosa is float32 and less than 1.
how to use x generated from pydub in librosa?

@mattc-eostar
Copy link

And how to change back to AudioSegment?

@jiaaro
Copy link
Owner

jiaaro commented Aug 1, 2019

@mattc-eostar That's covered in the docs:

from pydub import AudioSegment
sound = AudioSegment.from_file("sound1.wav")

samples = sound.get_array_of_samples()

# then modify samples...

new_sound = sound._spawn(samples)

@mattc-eostar
Copy link

mattc-eostar commented Aug 1, 2019 via email

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

Successfully merging a pull request may close this issue.

5 participants