marl / marl/pysox

Convert an ulaw byte array to a wav array

Open
#141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
540
Forks
83
PR merge metrics
No merged PRs in 30d

Description

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:

```python
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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue's Python example and inspect pysox's Transformer.build_array API, especially its input_array parameter and input format handling. Determine whether raw 8 kHz, 8-bit mono u-law bytes can be passed directly, and consider the conversion complete when the result is a 16 kHz, 16-bit mono WAV array without writing a temporary raw file.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.