Skip to content

Specifying raw type to build_array() #154

Description

@SamuelLarkin

Hi,
I'm attempting to translate

sox -r {SAMPLE_RATE} -b {BITS} -e {ENCODING} -c {NUM_CHANNEL} -t raw  {raw_audio_file.name} {wav_audio_file.name}

to a call to build_array() but I can't seem to be able to specify the equivalent of -t raw.

Code

tfm2wav = sox.Transformer()
tfm2wav.set_input_format(
    file_type="raw",
    rate=SAMPLE_RATE,
    bits=BITS,
    channels=NUM_CHANNEL,
    encoding=ENCODING,
    )
tfm2wav.set_output_format(
      file_type="wav",
      rate=SAMPLE_RATE,
      bits=BITS,
      channels=NUM_CHANNEL,
      encoding=ENCODING,
      )

audio = tfm2wav.build_array(
    input_filepath=raw_audio_file.name,
    )
tfm2wav.build_file(
     input_array=audio,
     output_filepath=wav_audio_file.name,
     sample_rate_in=SAMPLE_RATE,
     )

Error Message

{
  "errorMessage": "list index out of range",
  "errorType": "IndexError",
  "requestId": "d89c028b-e894-4596-89fd-0a9f19017103",
  "stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 103, in handler\n    raise e\n",
    "  File \"/var/task/lambda_function.py\", line 91, in handler\n    denoise(noisy_audio_file.name, denoised_audio_file.name)\n",
    "  File \"/var/task/lambda_function.py\", line 157, in denoise\n    audio = tfm2wav.build_array(\n",
    "  File \"/opt/python/sox/transform.py\", line 793, in build_array\n    encoding_out = [\n"
  ]
}
[ERROR]	2022-11-01T14:34:13.338Z	d89c028b-e894-4596-89fd-0a9f19017103	list index out of range
[ERROR] IndexError: list index out of range
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 103, in handler
    raise e
  File "/var/task/lambda_function.py", line 91, in handler
    denoise(noisy_audio_file.name, denoised_audio_file.name)
  File "/var/task/lambda_function.py", line 157, in denoise
    audio = tfm2wav.build_array(
  File "/opt/python/sox/transform.py", line 793, in build_array
    encoding_out = [END RequestId: d89c028b-e894-4596-89fd-0a9f19017103

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions