From 1362b50bfbf2b51423a9fbcad40e161a002a53b3 Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Wed, 26 Sep 2018 17:36:03 +0200 Subject: [PATCH] Enforce same sox options as libsox for C++ client Fixes #1594 --- native_client/javascript/client.js | 15 ++++++++++++++- native_client/python/client.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/native_client/javascript/client.js b/native_client/javascript/client.js index 5c7acdd939..3f6c78ac32 100644 --- a/native_client/javascript/client.js +++ b/native_client/javascript/client.js @@ -73,7 +73,20 @@ function bufferToStream(buffer) { var audioStream = new MemoryStream(); bufferToStream(buffer). - pipe(Sox({ output: { bits: 16, rate: 16000, channels: 1, type: 'raw' } })). + pipe(Sox({ + global: { + 'no-dither': true, + }, + output: { + bits: 16, + rate: 16000, + channels: 1, + encoding: 'signed-integer', + endian: 'little', + compression: 0.0, + type: 'raw' + } + })). pipe(audioStream); audioStream.on('finish', () => { diff --git a/native_client/python/client.py b/native_client/python/client.py index e9a1029adb..7becb3e0aa 100644 --- a/native_client/python/client.py +++ b/native_client/python/client.py @@ -41,7 +41,7 @@ N_CONTEXT = 9 def convert_samplerate(audio_path): - sox_cmd = 'sox {} --type raw --bits 16 --channels 1 --rate 16000 - '.format(quote(audio_path)) + sox_cmd = 'sox {} --type raw --bits 16 --channels 1 --rate 16000 --encoding signed-integer --endian little --compression 0.0 --no-dither - '.format(quote(audio_path)) try: output = subprocess.check_output(shlex.split(sox_cmd), stderr=subprocess.PIPE) except subprocess.CalledProcessError as e: