[autotest] sox_utils: Add method to convert raw file
Add utility to convert raw file to wav file.
BUG=chromium:560644
TEST=not used yet
Change-Id: I4409c07b252cca661a51494aa224d3aa8ad6de74
Reviewed-on: https://chromium-review.googlesource.com/313894
Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
diff --git a/client/cros/audio/sox_utils.py b/client/cros/audio/sox_utils.py
index 7ffb3b0..8ab277e 100644
--- a/client/cros/audio/sox_utils.py
+++ b/client/cros/audio/sox_utils.py
@@ -186,6 +186,25 @@
return stat
+def convert_raw_file(path_src, channels_src, bits_src, rate_src,
+ path_dst):
+ """Converts a raw file to a new format.
+
+ @param path_src: The path to the source file.
+ @param channels_src: The channel number of the source file.
+ @param bits_src: The size of sample in bits of the source file.
+ @param rate_src: The sampling rate of the source file.
+ @param path_dst: The path to the destination file. The file name determines
+ the new file format.
+
+ """
+ sox_cmd = [SOX_PATH]
+ sox_cmd += _raw_format_args(channels_src, bits_src, rate_src)
+ sox_cmd += [path_src]
+ sox_cmd += [path_dst]
+ cmd_utils.execute(sox_cmd)
+
+
def convert_format(path_src, channels_src, bits_src, rate_src,
path_dst, channels_dst, bits_dst, rate_dst,
volume_scale):