skit-ai / kaldi-serve

Server framework for Kaldi ASR Toolkit
Apache License 2.0
97 stars 24 forks source link

sample_rate_hertz has no effect #12

Closed cogmeta closed 4 years ago

cogmeta commented 4 years ago

Little bit confused by the behaviour that changing sample_rate_hertz in RecognitionConfig seems to have no effect. It is picking up sample rate from input file. Trying to write our own client and it always returns following error even when correct sample rate is provided in RecognitionConfig and input file is 16Khz wav file.

ERROR ([5.5.0~1457-eb28]:MaybeCreateResampler():online-feature.cc:99) Sampling frequency mismatch, expected 16000, got 8000

The issue is when sending raw:

  1. python scripts/example_client.py sample.wav --model=general --lang=en Works. Returns recognition results

  2. python scripts/example_client.py sample.wav --model=general --lang=en --raw Fails with Sampling frequency mismatch, expected 16000, got 8000

$soxi sample.wav

Input File : 'sample.wav' Channels : 1 Sample Rate : 16000 Precision : 16-bit Duration : 00:00:02.30 = 36816 samples ~ 172.575 CDDA sectors File Size : 73.7k Bit Rate : 256k Sample Encoding: 16-bit Signed Integer PCM

pskrunner14 commented 4 years ago

Hi @cogmeta thanks for reporting this. It was mainly due to a legacy sample rate assumption when doing raw audio decoding. Fixed just now.