Skip to content

Add GSM format support to save function #1264

@mthrok

Description

@mthrok

We would like to add more format support to "sox_io"'s save function. Full Rate is the codec used in mobile phone system and the libsox torchaudio binds have capability to handle this format.

Steps

Implementation

  1. Add GSM to Format enum and get_format_from_string function. The expected string form is "gsm".
  2. Add GSM branch in get_save_encoding function. Similar to the case MP3, GSM does not take any encoding or bit depth option. Use SOX_ENCODING_GSM, 16 for return value.
  3. Add GSM branch in get_precision function. the return value should be 16.

Update documentation

  1. Update the docstring of save function. (add "gsm" in format section then at the bottom before Note: add some explanation from http://sox.sourceforge.net/soxformat.html (do text search "gsm"

Add test

  1. Add a new method test_save_gsm to SaveTest class, following other method like test_save_flac. Only parameterize the test_mode. GSM does not support compression/encoding/bits_per_sample.

Building and testing locally

  1. Follow the CONTRIBUTING guide to set up development environment.
  2. Build and run test with;
BUILD_SOX=1 python setup.py develop && (cd test && pytest torchaudio_unittest/backend/sox_io/save_test.py -v --ff -k gsm )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions