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

Convert an ulaw byte array to a wav array #141

Open
r4nc0r opened this issue May 21, 2021 · 0 comments
Open

Convert an ulaw byte array to a wav array #141

r4nc0r opened this issue May 21, 2021 · 0 comments

Comments

@r4nc0r
Copy link

r4nc0r commented May 21, 2021

Hi,

i'm trying to convert a raw 8k,8bit,mono ulaw byte array to a 16k,16bit,mono wav array.
It works if i write the byte array to a .raw file and use pysox like this:

tfm = sox.Transformer()
tfm.set_input_format(rate=8000, channels=1, encoding="u-law",bits=8)
tfm.set_output_format(channels=1, rate=16000,bits=16)

def convert(data):
        f = open("randomfilename.raw", "wb")
        f.write(data)
        f.close()
        return (tfm.build_array(input_filepath="randomfilename.raw"))

But pysox has the capabilities to use build_array with an input_array parameter, but I dont know how to convert my byte array, so that it works.

Could you please help me?

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

1 participant