Skip to content

Commit

Permalink
Audio PR - Augmentation support [PreEmphasis Filter] (#122)
Browse files Browse the repository at this point in the history
* Audio Decoder PR 1

* channge image_info to sample_info to maintain a generic name for all the use-cases

* Change the copyright year from 2023 to 2024

* formatting the files

* Resolve PR comments

* NWC

* Resolve PR comments

* Change decoded_img_info to decoded_video_info

* Change the file_path() function to virtual from pure virtual

* Minor change

* Minor changes

* Add the unit test file

* Revert "Add the unit test file"

This reverts commit e79cc06.

* Fix the ROI api in python end

* Fix the ROI api in python end

* Remove the ROI change from pytorch.py

* Add Python Unit Test for Audio

* PreEmphasis Filter

* Add Preemp filter augmentations files

* Introduce CMake for sndfile

Modify CMakeLists.txt for the same

* Resolve 1st set of PR commenst

* Remove commented code for last batch polices and unsued imports

* ROI related changes - change from xy to wh to use for samples and channels

* Fix seg fault with ROI

* Remove opencv usage from the unit test

* Resolve the PR comments

* Remove instances of the audio_*_time - use the existing variables from Timing struct

* Formatting changes in rocal_api_data_loader.cpp and add the opencl and hip conditions for audio loaders

* Resolve the internal PR comments

* Reformatting the file_source_reader.cpp

* Remove _input_path from audio_source_evaluator and audio_read_and_decode as it is unecessary

* Change the header formatting

* Changes in copy_data() for audio samples

* Initialize the status at the beginning

* Resolve PR comments

* Resolving PR comments

* Resolve PR comments

* Remove the unused variables

* Resolve PR commensts

* Cmake related changes for audio

* Resolve PR comments

* Add condition check to eliminate any other file extensions other than a wav file / other image formats and call open_folder deom subfolder_reading() function

* Add basic testing for Audio to compare Bin files

* Update audio_read_and_decode.cpp

* Update rocAL_api_audio_unittest.py

* Revert file source reader changes

* Update master_graph.cpp

* Update tensor.cpp - Remove a commented line of code

* Rephrase

* Introduce ROCAL_AUDIO flag

Introduce flag for audio code, to be disabled when sndfile not found

* Minor changes

* Minor changes

* Add output comparision for Audio outputs

* Minor changes

* Add comment

* Minor changes to unit test

* Remove max_frames and max_channels args

* Remove max_frames, max_channels and sample rate from unit test

* Remove the NONE types

* Clean up unit test

* Clean up code in audio python unit test

* Introduce ROI in the unit test

* Minor change

* Format python unit test

* Add python script to run audio unittests

* Fix formatting issues - Minor changes

* Clean up C++ audio unit test

* Remove max frames and channels from decoder

* Minor changes

* Add Output comparison for python audio unittests

* Modify rocal audio unit test

Update README

* Minor change

* Resolve PR comments

* Minor changes - Modifying the names of the arguments

* Added a bried desc for the rocAL enum for border type

* Add a WRN statement in PreEmphasis Filter to only use FP32 dtype

* minor changes

* Change the borderType enum to int32 from uint32 dtype

* Minor changes

* Minor change

* Update README for audio unit test

* Parameters for rocALAudioIterator

* Minor change

* Remove the reset_tensor_roi() from the PreEmphasis augmentation making sure the src and dst roi points to the same location

* Del the Unit Test Files introduced earlier

* Add pre_emphasis function and gollden output comparison in audio unit tests

* minor change - add update val in create array

* Minor variable name change

* minor change

* Update unit test

* Minor change

* minor change

* Minor changes

Add wav extension in file reader
Add reader in unit test

* Minor change

* Add file reader to python audio unit test

* Update C++ unit test

* Update python audio unit test

* Remove the unused variable output - Resolve warnings in cpp unit test

* Remove the dst_roi arg passed to rpp

* Minor changes

Change borderType enum prefix

* Name change from sample to data

* Change from decoded_data_info to DecodedDataInfo

* Remove audio_decoder_factory.cpp file

* Minor change

* Change variable name

* Update the struct variable name in audio files

* Minor changes

* Change ROCAL_DATA_PATH to exclude rocal_data

* Update ROCAL_DATA_PATH to exclude rocal_data

* Use Pascal case for function names in audio decoder

* Modify cmake to have SNDFILE in all capital

* Minor changes

* Add struct for audio info in AudioReadAndDecode

* Fix merge conflict

* Renaming crop_image_info to CropImageInfo

* Remove - actual_host_buffers - Unused

* Rename TimingDBG to TimingDbg

* Move the instances of DecodedDataInfo to its base class LoaderModule

* Fix a WRN msg in master_graph.cpp

* Remove a dangling comment

* Rename _circ_data_info to _circ_buff_data_info

* Add Glob to CMakeLists.txt

* Rename SndFileDecoder to GenericAudioDecoder

* Fix build issues

* Minor change

* Update python API README.md for audio unit test

* Update audio unit test README

* Revert "Add Glob to CMakeLists.txt"

This reverts commit 47263d9.

* Fix include headers for Audio files

* Fix copy data 2D

* Minor changes

* Pass decoded data info to load routine instead of separate vectors

* Update CHANGELOG.md

* Update CHANGELOG.md

* Change swap_handle_time variable name in loader

* Update the changelog.md

* Formatting changes

Add comments

* Update doxygen comments

* Move file source reader from readers/image to readers folder

* Update README and add doxygen description

* Update CMakeLists and README for audio test

* Update README for audio test

* Minor fix

* Fix merge from PR 2

* Minor changes shard_count argument name

* Rename set and get functions of data_info to decoded_data_info

* Revert empty line removed in CMakeLists.txt

* Removed prefix original for audio vectors

* Resolve PR comments

* Add @params to all args in pytorch.py

* Minor changes in unit test

* Minor changes

* Change ROCAL instaces to rocAL in pytorch.py

* Resolve the PR comments

* Minor changes in decoders.py - Modify the comment for shard_size

* Minor changes

* Address the PR comments

* Address Review comments

---------

Co-authored-by: root <root@ixt-sjc2-54.local.lan>
Co-authored-by: Swetha B S <swetha@multicorwareinc.com>
Co-authored-by: fiona-gladwin <fionagladwin@multicorewareinc.com>
Co-authored-by: Fiona-MCW <70996026+fiona-gladwin@users.noreply.github.com>
Co-authored-by: Swetha B S <>
Co-authored-by: SundarRajan28 <sundarrajan@multicorewareinc.com>
Co-authored-by: Kiriti Gowda <kiritigowda@gmail.com>
  • Loading branch information
7 people authored Jun 5, 2024
1 parent 454346c commit 3fa8fa1
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Pytorch iterator for Audio
* Python audio unit test, and support to verify outputs
* rocDecode for HW decode
* Support for Audio augmentation - PreEmphasis filter

### Optimizations

Expand Down
17 changes: 17 additions & 0 deletions rocAL/include/api/rocal_api_augmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1098,4 +1098,21 @@ extern "C" RocalTensor ROCAL_API_CALL rocalSSDRandomCrop(RocalContext context, R
RocalTensorLayout output_layout = ROCAL_NONE,
RocalTensorOutputType output_datatype = ROCAL_UINT8);

/*! \brief Applies preemphasis filter to the input data.
* \ingroup group_rocal_augmentations
* \param [in] context Rocal context
* \param [in] input Input Rocal tensor
* \param [in] is_output Sets to True if the output tensor is part of the graph output
* \param [in] preemph_coeff Preemphasis coefficient
* \param [in] preemph_border_type Border value policy. Possible values are "zero", "clamp", "reflect".
* \param [in] output_datatype The data type of the output tensor
* \return RocalTensor
*/
extern "C" RocalTensor ROCAL_API_CALL rocalPreEmphasisFilter(RocalContext context,
RocalTensor input,
bool is_output,
RocalFloatParam preemph_coeff = NULL,
RocalAudioBorderType preemph_border_type = RocalAudioBorderType::ROCAL_CLAMP,
RocalTensorOutputType output_datatype = ROCAL_FP32);

#endif // MIVISIONX_ROCAL_API_AUGMENTATION_H
15 changes: 15 additions & 0 deletions rocAL/include/api/rocal_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,21 @@ enum RocalExternalSourceMode {
ROCAL_EXTSOURCE_RAW_UNCOMPRESSED = 2,
};

/*! \brief rocAL Audio Border Type enum
* \ingroup group_rocal_types
*/
enum RocalAudioBorderType {
/*! \brief AMD ROCAL_ZERO
*/
ROCAL_ZERO = 0,
/*! \brief AMD ROCAL_CLAMP
*/
ROCAL_CLAMP = 1,
/*! \brief AMD ROCAL_REFLECT
*/
ROCAL_REFLECT = 2
};

/*! \brief Tensor Last Batch Policies
* \ingroup group_rocal_types
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#pragma once
#include "pipeline/graph.h"
#include "pipeline/node.h"
#include "parameters/parameter_factory.h"
#include "parameters/parameter_vx.h"
#include "rocal_api_types.h"

class PreemphasisFilterNode : public Node {
public:
PreemphasisFilterNode(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs);
PreemphasisFilterNode() = delete;
void init(FloatParam *preemph_coeff, RocalAudioBorderType preemph_border);

protected:
void create_node() override;
void update_node() override;

private:
ParameterVX<float> _preemph_coeff;
constexpr static float PREEMPH_COEFF_RANGE[2] = {0.97, 0.97};
RocalAudioBorderType _preemph_border;
};
1 change: 1 addition & 0 deletions rocAL/include/augmentations/augmentations_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ THE SOFTWARE.
#include "augmentations/node_copy.h"
#include "augmentations/node_nop.h"
#include "augmentations/node_sequence_rearrange.h"
#include "augmentations/audio_augmentations/node_preemphasis_filter.h"
32 changes: 32 additions & 0 deletions rocAL/source/api/rocal_api_augmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2155,3 +2155,35 @@ rocalNop(
}
return output;
}

RocalTensor ROCAL_API_CALL
rocalPreEmphasisFilter(RocalContext p_context,
RocalTensor p_input,
bool is_output,
RocalFloatParam p_preemph_coeff,
RocalAudioBorderType preemph_border_type,
RocalTensorOutputType output_datatype) {
Tensor* output = nullptr;
if ((p_context == nullptr) || (p_input == nullptr)) {
ERR("Invalid ROCAL context or invalid input tensor")
return output;
}
auto context = static_cast<Context*>(p_context);
auto input = static_cast<Tensor*>(p_input);
auto preemph_coeff = static_cast<FloatParam*>(p_preemph_coeff);
try {
RocalTensorDataType op_tensor_datatype = static_cast<RocalTensorDataType>(output_datatype);
if (op_tensor_datatype != RocalTensorDataType::FP32) {
WRN("Only FP32 dtype is supported for PreEmphasis filter augmentation.")
op_tensor_datatype = RocalTensorDataType::FP32;
}
TensorInfo output_info = input->info();
output_info.set_data_type(op_tensor_datatype);
output = context->master_graph->create_tensor(output_info, is_output);
context->master_graph->add_node<PreemphasisFilterNode>({input}, {output})->init(preemph_coeff, preemph_border_type);
} catch (const std::exception& e) {
context->capture_error(e.what());
ERR(e.what())
}
return output;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include <vx_ext_rpp.h>
#include "augmentations/audio_augmentations/node_preemphasis_filter.h"
#include "pipeline/exception.h"

PreemphasisFilterNode::PreemphasisFilterNode(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) : Node(inputs, outputs),
_preemph_coeff(PREEMPH_COEFF_RANGE[0], PREEMPH_COEFF_RANGE[1]) {}

void PreemphasisFilterNode::create_node() {
if (_node)
return;
_preemph_coeff.create_array(_graph, VX_TYPE_FLOAT32, _batch_size);
vx_scalar border_type_vx = vxCreateScalar(vxGetContext((vx_reference)_graph->get()), VX_TYPE_INT32, &_preemph_border);
_node = vxExtRppPreemphasisFilter(_graph->get(), _inputs[0]->handle(), _inputs[0]->get_roi_tensor(), _outputs[0]->handle(), _preemph_coeff.default_array(), border_type_vx);
vx_status status;
if ((status = vxGetStatus((vx_reference)_node)) != VX_SUCCESS)
THROW("Adding the vxExtRppPreemphasisFilter node failed: " + TOSTR(status))
}

void PreemphasisFilterNode::update_node() {
_preemph_coeff.update_array();
}

void PreemphasisFilterNode::init(FloatParam *preemph_coeff, RocalAudioBorderType preemph_border) {
if (preemph_coeff == nullptr)
ERR("Invalid pre-Emphasis co-efficient passed")
_preemph_coeff.set_param(core(preemph_coeff));
_preemph_border = preemph_border;
}
36 changes: 35 additions & 1 deletion rocAL_pybind/amd/rocal/fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,17 @@ def box_iou_matcher(*inputs, anchors, high_threshold=0.5,
return (box_iou_matcher, [])


def external_source(*inputs, source, device=None, color_format=types.RGB, random_shuffle=False, mode=types.EXTSOURCE_FNAME, max_width=2000, max_height=2000):
def external_source(source, device=None, color_format=types.RGB, random_shuffle=False, mode=types.EXTSOURCE_FNAME, max_width=2000, max_height=2000):
"""
External Source Reader - User can pass a iterator or callable source.
@param source (iterator or callable) The source iterator or callable object.
@param device (string, optional, default = None) Parameter unused for augmentation
@color_format (type, optional, default = RGB) Tensor color format for the reader. Default is RGB format.
@random_shuffle (bool, optional, default= False) Data would be randomly shuffled if set to True.
@mode (type, optional, default = EXTSOURCE_FNAME) The Default mode would be External Source File Name. The External Source Mode can be FileName, Raw Compressed, Raw Uncompressed.
@max_width (int, optional, default = 2000) The Max Width to which the source images would be decoded to.
@max_height (int, optional, default = 2000) The Max Height to which the source images would be decoded to.
"""
# pybind call arguments
Pipeline._current_pipeline._is_external_source_operator = True
Pipeline._current_pipeline._external_source = iter(source)
Expand All @@ -1068,3 +1078,27 @@ def external_source(*inputs, source, device=None, color_format=types.RGB, random
external_source_operator = b.externalFileSource(
Pipeline._current_pipeline._handle, *(kwargs_pybind.values()))
return (external_source_operator, []) # Labels is Empty

def preemphasis_filter(*inputs, border=types.CLAMP, preemph_coeff=0.97, output_dtype=types.FLOAT):
"""
Applies preemphasis filter to the input data.
This filter, in simple form, can be expressed by the formula:
Y[t] = X[t] - coeff * X[t-1] if t > 1
Y[t] = X[t] - coeff * X_border if t == 0
with X and Y being the input and output signal, respectively.
The value of X_border depends on the border argument:
X_border = 0 if border_type == 'zero'
X_border = X[0] if border_type == 'clamp'
X_border = X[1] if border_type == 'reflect'
@param inputs (list) The input sample to which preEmphasisFilter is applied.
@param border The border value policy. The possible values are "CLAMP", "ZERO", "REFLECT"
@param preemph_coeff (float , optional, default = 0.97) The preEmphasisFilter co-efficient.
@output_dtype (type, optional, default = types.FLOAT) Tensor dtype for the augmentation output. Default is types.FLOAT.
"""
preemph_coeff_float_param = b.createFloatParameter(preemph_coeff)
kwargs_pybind = {"input_audio0": inputs[0], "is_output": False,
"preemph_coeff": preemph_coeff_float_param, "preemph_border_type": border,
"output_dtype" :output_dtype}
preemphasis_output = b.preEmphasisFilter(Pipeline._current_pipeline._handle ,*(kwargs_pybind.values()))
return (preemphasis_output)
9 changes: 9 additions & 0 deletions rocAL_pybind/amd/rocal/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
from rocal_pybind.types import EXTSOURCE_RAW_COMPRESSED
from rocal_pybind.types import EXTSOURCE_RAW_UNCOMPRESSED

# RocalAudioBorderType
from rocal_pybind.types import ZERO
from rocal_pybind.types import CLAMP
from rocal_pybind.types import REFLECT

# RocalLastBatchPolicy
from rocal_pybind.types import LAST_BATCH_FILL
from rocal_pybind.types import LAST_BATCH_DROP
Expand Down Expand Up @@ -158,6 +163,10 @@
EXTSOURCE_RAW_COMPRESSED: ("EXTSOURCE_RAW_COMPRESSED", EXTSOURCE_RAW_COMPRESSED),
EXTSOURCE_RAW_UNCOMPRESSED: ("EXTSOURCE_RAW_UNCOMPRESSED", EXTSOURCE_RAW_UNCOMPRESSED),

ZERO: ("ZERO", ZERO),
CLAMP: ("CLAMP", CLAMP),
REFLECT: ("REFLECT", REFLECT),

LAST_BATCH_FILL : ("LAST_BATCH_FILL", LAST_BATCH_FILL),
LAST_BATCH_DROP : ("LAST_BATCH_DROP", LAST_BATCH_DROP),
LAST_BATCH_PARTIAL : ("LAST_BATCH_PARTIAL", LAST_BATCH_PARTIAL),
Expand Down
7 changes: 7 additions & 0 deletions rocAL_pybind/rocal_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ PYBIND11_MODULE(rocal_pybind, m) {
.value("EXTSOURCE_RAW_COMPRESSED", ROCAL_EXTSOURCE_RAW_COMPRESSED)
.value("EXTSOURCE_RAW_UNCOMPRESSED", ROCAL_EXTSOURCE_RAW_UNCOMPRESSED)
.export_values();
py::enum_<RocalAudioBorderType>(types_m,"RocalAudioBorderType", "Rocal Audio Border Type")
.value("ZERO", ROCAL_ZERO)
.value("CLAMP", ROCAL_CLAMP)
.value("REFLECT", ROCAL_REFLECT)
.export_values();
py::enum_<RocalLastBatchPolicy>(types_m, "RocalLastBatchPolicy", "Rocal Last Batch Policy")
.value("LAST_BATCH_FILL", ROCAL_LAST_BATCH_FILL)
.value("LAST_BATCH_DROP", ROCAL_LAST_BATCH_DROP)
Expand Down Expand Up @@ -716,5 +721,7 @@ PYBIND11_MODULE(rocal_pybind, m) {
py::return_value_policy::reference);
m.def("lensCorrection", &rocalLensCorrection,
py::return_value_policy::reference);
m.def("preEmphasisFilter", &rocalPreEmphasisFilter,
py::return_value_policy::reference);
}
} // namespace rocal
1 change: 1 addition & 0 deletions tests/cpp_api/audio_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ python3 audio_tests.py --gpu <0/1> --downmix <True/False> --test_case <case_numb

**Available Test Cases**
* Case 0 - Audio Decoder
* Case 1 - PreEmphasis Filter
9 changes: 9 additions & 0 deletions tests/cpp_api/audio_tests/audio_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ int test(int test_case, const char *path, int qa_mode, int downmix, int gpu) {
case_name = "audio_decoder";
std::cout << "Running AUDIO DECODER" << std::endl;
} break;
case 1: {
std::cout << "Running PREEMPHASIS" << std::endl;
case_name = "preemphasis_filter";
RocalTensorOutputType tensorOutputType = RocalTensorOutputType::ROCAL_FP32;
RocalAudioBorderType preemph_border_type = RocalAudioBorderType::ROCAL_CLAMP;
RocalFloatParam p_preemph_coeff = rocalCreateFloatParameter(0.97);
rocalPreEmphasisFilter(handle, decoded_output, true, p_preemph_coeff, preemph_border_type, tensorOutputType);

} break;
default: {
std::cout << "Not a valid test case ! Exiting!\n";
return -1;
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp_api/audio_tests/audio_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import argparse

test_case_augmentation_map = {
0: "audio_decoder"
0: "audio_decoder",
1: "preemphasis_filter"
}

def run_unit_test(src_path, qa_mode, gpu, downmix, build_folder_path, case_list):
Expand Down
3 changes: 2 additions & 1 deletion tests/python_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ python3 audio_unit_test.py --audio_path=<path_to_data> --test_case <case(0-1)> -
```

**Available Test Cases**
* Case 0 - Audio Decoder
* Case 0 - Audio Decoder
* Case 1 - PreEmphasis Filter
15 changes: 15 additions & 0 deletions tests/python_api/audio_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

test_case_augmentation_map = {
0: "audio_decoder",
1: "preemphasis_filter"
}

def plot_audio_wav(audio_tensor, idx):
Expand Down Expand Up @@ -80,6 +81,18 @@ def audio_decoder_pipeline(path):
num_shards=1,
stick_to_shard=False)

@pipeline_def(seed=seed)
def pre_emphasis_filter_pipeline(path):
audio, labels = fn.readers.file(file_root=path)
decoded_audio = fn.decoders.audio(
audio,
file_root=path,
downmix=False,
shard_id=0,
num_shards=1,
stick_to_shard=False)
return fn.preemphasis_filter(decoded_audio)

def main():
args = parse_args()

Expand Down Expand Up @@ -131,6 +144,8 @@ def main():
case_name = test_case_augmentation_map.get(case)
if case_name == "audio_decoder":
audio_pipeline = audio_decoder_pipeline(batch_size=batch_size, num_threads=num_threads, device_id=device_id, rocal_cpu=rocal_cpu, path=audio_path)
if case_name == "preemphasis_filter":
audio_pipeline = pre_emphasis_filter_pipeline(batch_size=batch_size, num_threads=num_threads, device_id=device_id, rocal_cpu=rocal_cpu, path=audio_path)
audio_pipeline.build()
audio_loader = ROCALAudioIterator(audio_pipeline, auto_reset=True)
cnt = 0
Expand Down
2 changes: 1 addition & 1 deletion tests/python_api/parse_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def parse_args():
'audio-python-unittest', 'audio-python-unittest-related options')
audio_unit_test.add_argument('--audio_path', type=str, default="",
help='audio files path')
audio_unit_test.add_argument('--test_case', type=int, default=0,
audio_unit_test.add_argument('--test_case', type=int, default=None,
help='test case')
audio_unit_test.add_argument('--qa_mode', type=int, default=1,
help='enable qa mode to compare audio output with ref outputs')
Expand Down

0 comments on commit 3fa8fa1

Please sign in to comment.