Skip to content

Commit

Permalink
Merge pull request #1595 from lissyx/fix-nodejs-python-prod
Browse files Browse the repository at this point in the history
Enforce same sox options as libsox for C++ client
  • Loading branch information
lissyx authored Sep 26, 2018
2 parents e17105f + 1362b50 commit 1546576
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion native_client/javascript/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion native_client/python/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1546576

Please sign in to comment.