Fix modified beam search for iOS and android (#76)
* Use Int type for sampling rate * Fix swift * Fix iOS
This commit is contained in:
@@ -48,7 +48,7 @@ class FeatureExtractor::Impl {
|
||||
fbank_ = std::make_unique<knf::OnlineFbank>(opts_);
|
||||
}
|
||||
|
||||
void AcceptWaveform(float sampling_rate, const float *waveform, int32_t n) {
|
||||
void AcceptWaveform(int32_t sampling_rate, const float *waveform, int32_t n) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
fbank_->AcceptWaveform(sampling_rate, waveform, n);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ FeatureExtractor::FeatureExtractor(const FeatureExtractorConfig &config /*={}*/)
|
||||
|
||||
FeatureExtractor::~FeatureExtractor() = default;
|
||||
|
||||
void FeatureExtractor::AcceptWaveform(float sampling_rate,
|
||||
void FeatureExtractor::AcceptWaveform(int32_t sampling_rate,
|
||||
const float *waveform, int32_t n) {
|
||||
impl_->AcceptWaveform(sampling_rate, waveform, n);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace sherpa_onnx {
|
||||
|
||||
struct FeatureExtractorConfig {
|
||||
float sampling_rate = 16000;
|
||||
int32_t sampling_rate = 16000;
|
||||
int32_t feature_dim = 80;
|
||||
int32_t max_feature_vectors = -1;
|
||||
|
||||
@@ -34,7 +34,7 @@ class FeatureExtractor {
|
||||
@param waveform Pointer to a 1-D array of size n
|
||||
@param n Number of entries in waveform
|
||||
*/
|
||||
void AcceptWaveform(float sampling_rate, const float *waveform, int32_t n);
|
||||
void AcceptWaveform(int32_t sampling_rate, const float *waveform, int32_t n);
|
||||
|
||||
/**
|
||||
* InputFinished() tells the class you won't be providing any
|
||||
|
||||
@@ -112,7 +112,7 @@ for a list of pre-trained models to download.
|
||||
|
||||
param.suggestedLatency = info->defaultLowInputLatency;
|
||||
param.hostApiSpecificStreamInfo = nullptr;
|
||||
const float sample_rate = 16000;
|
||||
float sample_rate = 16000;
|
||||
|
||||
PaStream *stream;
|
||||
PaError err =
|
||||
|
||||
@@ -61,7 +61,7 @@ for a list of pre-trained models to download.
|
||||
|
||||
sherpa_onnx::OnlineRecognizer recognizer(config);
|
||||
|
||||
float expected_sampling_rate = config.feat_config.sampling_rate;
|
||||
int32_t expected_sampling_rate = config.feat_config.sampling_rate;
|
||||
|
||||
bool is_ok = false;
|
||||
std::vector<float> samples =
|
||||
@@ -72,7 +72,7 @@ for a list of pre-trained models to download.
|
||||
return -1;
|
||||
}
|
||||
|
||||
float duration = samples.size() / expected_sampling_rate;
|
||||
float duration = samples.size() / static_cast<float>(expected_sampling_rate);
|
||||
|
||||
fprintf(stderr, "wav filename: %s\n", wav_filename.c_str());
|
||||
fprintf(stderr, "wav duration (s): %.3f\n", duration);
|
||||
|
||||
Reference in New Issue
Block a user