Commit 36cad857 authored by Jan "yenda" Trmal's avatar Jan "yenda" Trmal
Browse files

Merge pull request #8 from jtrmal/windows-test-fixes

Windows test fixes
parents db63ae29 b0439a2e
......@@ -27,7 +27,7 @@
#include <sstream>
#include <cstdio>
#if _MSC_VER >= 0x1400 || !defined(MSC_VER) && __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
#if _MSC_VER >= 1900 || (!defined(_MSC_VER) && __cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__)
#define NOEXCEPT(Predicate) noexcept((Predicate))
#else
#define NOEXCEPT(Predicate)
......
......@@ -18,6 +18,7 @@
// limitations under the License.
#include "base/kaldi-math.h"
#include "base/timer.h"
#include <limits>
namespace kaldi {
......@@ -25,8 +26,10 @@ template<class I> void UnitTestGcdLcmTpl() {
for (I a = 1; a < 15; a++) { // a is min gcd.
I b = (I)(Rand() % 10);
I c = (I)(Rand() % 10);
if (Rand()%2 == 0 && std::numeric_limits<I>::is_signed) b = -b;
if (Rand()%2 == 0 && std::numeric_limits<I>::is_signed) c = -c;
if (std::numeric_limits<I>::is_signed) {
if (Rand() % 2 == 0) b = -b;
if (Rand() % 2 == 0) c = -c;
}
if (b == 0 && c == 0) continue; // gcd not defined for such numbers.
I g = Gcd(b*a, c*a);
KALDI_ASSERT(g >= a);
......@@ -157,14 +160,14 @@ void UnitTestLogAddSub() {
using namespace kaldi;
for (int i = 0; i < 100; i++) {
double f1 = Rand() % 10000, f2 = Rand() % 20;
double add1 = exp(LogAdd(log(f1), log(f2)));
double add2 = exp(LogAdd(log(f2), log(f1)));
double add1 = Exp(LogAdd(Log(f1), Log(f2)));
double add2 = Exp(LogAdd(Log(f2), Log(f1)));
double add = f1 + f2, thresh = add*0.00001;
KALDI_ASSERT(std::abs(add-add1) < thresh && std::abs(add-add2) < thresh);
try {
double f2_check = exp(LogSub(log(add), log(f1))), thresh = (f2*0.01)+0.001;
double f2_check = Exp(LogSub(Log(add), Log(f1))), thresh = (f2*0.01)+0.001;
KALDI_ASSERT(std::abs(f2_check-f2) < thresh);
} catch(...) {
KALDI_ASSERT(f2 == 0); // It will probably crash for f2=0.
......@@ -173,8 +176,8 @@ void UnitTestLogAddSub() {
}
void UnitTestDefines() { // Yes, we even unit-test the preprocessor statements.
KALDI_ASSERT(exp(kLogZeroFloat) == 0.0);
KALDI_ASSERT(exp(kLogZeroDouble) == 0.0);
KALDI_ASSERT(Exp(kLogZeroFloat) == 0.0);
KALDI_ASSERT(Exp(kLogZeroDouble) == 0.0);
BaseFloat den = 0.0;
KALDI_ASSERT(KALDI_ISNAN(0.0 / den));
KALDI_ASSERT(!KALDI_ISINF(0.0 / den));
......@@ -194,8 +197,8 @@ void UnitTestDefines() { // Yes, we even unit-test the preprocessor statements.
&& "If this test fails, you can probably just comment it out-- may mean your CPU exceeds expected floating point precision");
KALDI_ASSERT(std::abs(sin(M_PI)) < 1.0e-05 && std::abs(cos(M_PI)+1.0) < 1.0e-05);
KALDI_ASSERT(std::abs(sin(M_2PI)) < 1.0e-05 && std::abs(cos(M_2PI)-1.0) < 1.0e-05);
KALDI_ASSERT(std::abs(sin(exp(M_LOG_2PI))) < 1.0e-05);
KALDI_ASSERT(std::abs(cos(exp(M_LOG_2PI)) - 1.0) < 1.0e-05);
KALDI_ASSERT(std::abs(sin(Exp(M_LOG_2PI))) < 1.0e-05);
KALDI_ASSERT(std::abs(cos(Exp(M_LOG_2PI)) - 1.0) < 1.0e-05);
}
void UnitTestAssertFunc() { // Testing Assert** *functions
......
......@@ -75,6 +75,51 @@
namespace kaldi {
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
inline double Exp(double x) { return exp(x); }
#ifndef KALDI_NO_EXPF
inline float Exp(float x) { return expf(x); }
#else
inline float Exp(float x) { return exp(static_cast<double>(x)); }
#endif // KALDI_NO_EXPF
#else
inline double Exp(double x) { return exp(x); }
#if !defined(__INTEL_COMPILER) && _MSC_VER == 1800 && defined(_M_X64)
// Microsoft CL v18.0 buggy 64-bit implementation of
// expf() incorrectly returns -inf for exp(-inf).
inline float Exp(float x) { return exp(static_cast<double>(x)); }
#else
inline float Exp(float x) { return expf(x); }
#endif // !defined(__INTEL_COMPILER) && _MSC_VER == 1800 && defined(_M_X64)
#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
inline double Log(double x) { return log(x); }
inline float Log(float x) { return logf(x); }
#if !defined(_MSC_VER) || (_MSC_VER >= 1700)
inline double Log1p(double x) { return log1p(x); }
inline float Log1p(float x) { return log1pf(x); }
#else
inline double Log1p(double x) {
const double cutoff = 1.0e-08;
if (x < cutoff)
return x - 2 * x * x;
else
return Log(1.0 + x);
}
inline float Log1p(float x) {
const float cutoff = 1.0e-07;
if (x < cutoff)
return x - 2 * x * x;
else
return Log(1.0 + x);
}
#endif
static const double kMinLogDiffDouble = Log(DBL_EPSILON); // negative!
static const float kMinLogDiffFloat = Log(FLT_EPSILON); // negative!
// -infinity
const float kLogZeroFloat = -std::numeric_limits<float>::infinity();
const double kLogZeroDouble = -std::numeric_limits<double>::infinity();
......@@ -103,7 +148,7 @@ inline float RandUniform(struct RandomState* state = NULL) {
}
inline float RandGauss(struct RandomState* state = NULL) {
return static_cast<float>(sqrtf (-2 * logf(RandUniform(state)))
return static_cast<float>(sqrtf (-2 * Log(RandUniform(state)))
* cosf(2*M_PI*RandUniform(state)));
}
......@@ -129,8 +174,6 @@ inline Float RandPrune(Float post, BaseFloat prune_thresh, struct RandomState* s
(RandUniform(state) <= fabs(post)/prune_thresh ? prune_thresh : 0.0);
}
static const double kMinLogDiffDouble = std::log(DBL_EPSILON); // negative!
static const float kMinLogDiffFloat = std::log(FLT_EPSILON); // negative!
inline double LogAdd(double x, double y) {
double diff;
......@@ -144,13 +187,7 @@ inline double LogAdd(double x, double y) {
if (diff >= kMinLogDiffDouble) {
double res;
#if _MSC_VER >= 1800 || __cplusplus >= 201103L
res = x + std::log1p(std::exp(diff));
#elif defined _MSC_VER
res = x + log(1.0 + exp(diff));
#else
res = x + log1p(exp(diff));
#endif
res = x + Log1p(Exp(diff));
return res;
} else {
return x; // return the larger one.
......@@ -170,13 +207,7 @@ inline float LogAdd(float x, float y) {
if (diff >= kMinLogDiffFloat) {
float res;
#if _MSC_VER >= 1800 || __cplusplus >= 201103L
res = x + std::log1p(std::exp(diff));
#elif defined _MSC_VER
res = x + logf(1.0 + expf(diff));
#else
res = x + log1pf(expf(diff));
#endif
res = x + Log1p(Exp(diff));
return res;
} else {
return x; // return the larger one.
......@@ -194,7 +225,7 @@ inline double LogSub(double x, double y) {
}
double diff = y - x; // Will be negative.
double res = x + log(1.0 - exp(diff));
double res = x + Log(1.0 - Exp(diff));
// res might be NAN if diff ~0.0, and 1.0-exp(diff) == 0 to machine precision
if (KALDI_ISNAN(res))
......@@ -213,7 +244,7 @@ inline float LogSub(float x, float y) {
}
float diff = y - x; // Will be negative.
float res = x + logf(1.0 - expf(diff));
float res = x + Log(1.0f - Exp(diff));
// res might be NAN if diff ~0.0, and 1.0-exp(diff) == 0 to machine precision
if (KALDI_ISNAN(res))
......@@ -301,42 +332,9 @@ template<class I> void Factorize(I m, std::vector<I> *factors) {
}
inline double Hypot(double x, double y) { return hypot(x, y); }
inline float Hypot(float x, float y) { return hypotf(x, y); }
#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
inline double Log1p(double x) { return log1p(x); }
inline float Log1p(float x) { return log1pf(x); }
#else
inline double Log1p(double x) {
const double cutoff = 1.0e-08;
if (x < cutoff)
return x - 2 * x * x;
else
return log(1.0 + x);
}
inline float Log1p(float x) {
const float cutoff = 1.0e-07;
if (x < cutoff)
return x - 2 * x * x;
else
return log(1.0 + x);
}
#endif
inline double Exp(double x) { return exp(x); }
#ifndef KALDI_NO_EXPF
inline float Exp(float x) { return expf(x); }
#else
inline float Exp(float x) { return exp(x); }
#endif
inline double Log(double x) { return log(x); }
inline float Log(float x) { return logf(x); }
} // namespace kaldi
......
......@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
// sort the counts
std::vector<std::pair<int32,int32> > sorted_counts;
for (int32 i = 0; i < counts.size(); i++) {
sorted_counts.push_back(std::make_pair(counts[i], i));
sorted_counts.push_back(std::make_pair(static_cast<int32>(counts[i]), i));
}
std::sort(sorted_counts.begin(), sorted_counts.end());
......
......@@ -71,7 +71,7 @@ int main(int argc, char *argv[]) {
// means it's more comparable with MMI/MPE.
BaseFloat den_score = den_score_reader.Value(key);
BaseFloat score_difference = mce_alpha * (num_score - den_score) + mce_beta;
BaseFloat sigmoid_difference = 1.0 / (1.0 + exp(score_difference));
BaseFloat sigmoid_difference = 1.0 / (1.0 + Exp(score_difference));
// It might be more natural to make the scale
//
BaseFloat scale = 4.0 * sigmoid_difference * (1 - sigmoid_difference);
......
......@@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
KALDI_ASSERT(quantize >= 0.0 && quantize <= 1.0);
double sil_log_bias = log(sil_prior / (1.0 - sil_prior));
double sil_log_bias = Log(sil_prior / (1.0 - sil_prior));
std::string silence_likes_rspecifier = po.GetArg(1),
nonsilence_likes_rspecifier = po.GetArg(2),
......@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
if (sil_loglike > 10) {
sil_probs(f) = 1.0; // because the exp below might fail.
} else {
BaseFloat e_sil_loglike = exp(sil_loglike);
BaseFloat e_sil_loglike = Exp(sil_loglike);
BaseFloat sil_prob = e_sil_loglike / (1.0 + e_sil_loglike);
if ( !(sil_prob >= 0.0 && sil_prob <= 1.0)) {
KALDI_WARN << "Bad silence prob (NaNs found?), setting to 0.5";
......
......@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
for (int32 i = 0; i < logprobs.NumRows(); i++) {
SubVector<BaseFloat> row(logprobs, i);
for (int32 j = 0; j < row.Dim(); j++) {
BaseFloat p = exp(row(j));
BaseFloat p = Exp(row(j));
if (p >= min_post) {
post[i].push_back(std::make_pair(j, p));
} else if (random_prune && (p / min_post) >= RandUniform()) {
......
......@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
if (weight < threshold) weight *= scale;
total_weight_out += weight;
if (weight != 0.0)
new_post[i].push_back(std::make_pair(tid, weight));
new_post[i].push_back(std::make_pair(tid, static_cast<BaseFloat>(weight)));
}
}
posterior_writer.Write(posterior_reader.Key(), new_post);
......
......@@ -1621,7 +1621,7 @@ static void UnitTestCuDiffXent() {
//cpu
for(MatrixIndexT r=0; r<Hi.NumRows(); r++) {
int32 col_tgt = Htgt[r];
Hlogpost(r) = log(Hi(r, col_tgt));
Hlogpost(r) = Log(Hi(r, col_tgt));
Hi(r, col_tgt) -= 1.0;
}
......
......@@ -1193,7 +1193,7 @@ void CuMatrix<Real>::CompObjfAndDeriv(const std::vector<MatrixElement<Real> >& s
//KALDI_ASSERT(label >= 0 && label < nnet_.OutputDim());
Real this_prob = output(m, label);
KALDI_ASSERT(this_prob >= 0.99e-20); // we floored to 1.0e-20 in SoftmaxLayer.
*tot_objf += weight * log(this_prob);
*tot_objf += weight * Log(this_prob);
*tot_weight += weight;
(*this)(m, label) += weight / this_prob;
}
......@@ -1399,7 +1399,7 @@ void CuMatrixBase<Real>::DiffXent(const CuArray<int32> &tgt,
for(int32 r = 0; r < num_rows; r++) {
int32 col_tgt = tgt.Data()[r];
Real &value = Mat()(r, col_tgt);
log_post_tgt->Vec()(r) = log(value);
log_post_tgt->Vec()(r) = Log(value);
value -= 1.0;
}
}
......
......@@ -463,7 +463,7 @@ template<typename Real> void CuVectorUnitTestApplyExp() {
vector.ApplyExp();
for(int32 j = 0; j < dim; j++) {
//std::cout<<"diff is "<<exp(vector2(j))-vector(j)<<std::endl;;
KALDI_ASSERT(std::abs(exp(vector2(j))-vector(j)) < 0.000001 );
KALDI_ASSERT(std::abs(Exp(vector2(j))-vector(j)) < 0.000001 );
}
}
......@@ -482,7 +482,7 @@ template<typename Real> void CuVectorUnitTestApplyLog() {
vector.ApplyLog();
for(int32 j = 0; j < dim; j++) {
//std::cout<<"diff is "<<exp(vector2(j))-vector(j)<<std::endl;;
KALDI_ASSERT(std::abs(log(vector2(j))-vector(j)) < 0.000001 );
KALDI_ASSERT(std::abs(Log(vector2(j))-vector(j)) < 0.000001 );
}
}
......
......@@ -26,7 +26,7 @@ namespace kaldi {
Fbank::Fbank(const FbankOptions &opts)
: opts_(opts), feature_window_function_(opts.frame_opts), srfft_(NULL) {
if (opts.energy_floor > 0.0)
log_energy_floor_ = log(opts.energy_floor);
log_energy_floor_ = Log(opts.energy_floor);
int32 padded_window_size = opts.frame_opts.PaddedWindowSize();
if ((padded_window_size & (padded_window_size-1)) == 0) // Is a power of two...
......@@ -136,7 +136,7 @@ void Fbank::ComputeInternal(const VectorBase<BaseFloat> &wave,
// Compute energy after window function (not the raw one)
if (opts_.use_energy && !opts_.raw_energy)
log_energy = log(std::max(VecVec(window, window),
log_energy = Log(std::max(VecVec(window, window),
std::numeric_limits<BaseFloat>::min()));
if (srfft_ != NULL) // Compute FFT using split-radix algorithm.
......
......@@ -153,7 +153,7 @@ void ExtractWindow(const VectorBase<BaseFloat> &wave,
if (log_energy_pre_window != NULL) {
BaseFloat energy = std::max(VecVec(window_part, window_part),
std::numeric_limits<BaseFloat>::min());
*log_energy_pre_window = log(energy);
*log_energy_pre_window = Log(energy);
}
if (opts.preemph_coeff != 0.0)
......@@ -385,7 +385,7 @@ BaseFloat ComputeLpc(const VectorBase<BaseFloat> &autocorr_in,
tmp.Data());
if (ans <= 0.0)
KALDI_WARN << "Zero energy in LPC computation";
return -log((double)1.0/ans); // forms the C0 value
return -Log((double)1.0/ans); // forms the C0 value
}
void SpliceFrames(const MatrixBase<BaseFloat> &input_features,
......
......@@ -39,7 +39,7 @@ Mfcc::Mfcc(const MfccOptions &opts)
ComputeLifterCoeffs(opts.cepstral_lifter, &lifter_coeffs_);
}
if (opts.energy_floor > 0.0)
log_energy_floor_ = log(opts.energy_floor);
log_energy_floor_ = Log(opts.energy_floor);
int32 padded_window_size = opts.frame_opts.PaddedWindowSize();
if ((padded_window_size & (padded_window_size-1)) == 0) // Is a power of two...
......@@ -138,7 +138,7 @@ void Mfcc::ComputeInternal(const VectorBase<BaseFloat> &wave,
(opts_.use_energy && opts_.raw_energy ? &log_energy : NULL));
if (opts_.use_energy && !opts_.raw_energy)
log_energy = log(std::max(VecVec(window, window),
log_energy = Log(std::max(VecVec(window, window),
std::numeric_limits<BaseFloat>::min()));
if (srfft_ != NULL) // Compute FFT using the split-radix algorithm.
......
......@@ -34,7 +34,7 @@ Plp::Plp(const PlpOptions &opts)
&idft_bases_);
if (opts.energy_floor > 0.0)
log_energy_floor_ = log(opts.energy_floor);
log_energy_floor_ = Log(opts.energy_floor);
int32 padded_window_size = opts.frame_opts.PaddedWindowSize();
if ((padded_window_size & (padded_window_size-1)) == 0) // Is a power of two...
......@@ -193,7 +193,7 @@ void Plp::ComputeInternal(const VectorBase<BaseFloat> &wave,
(opts_.use_energy && opts_.raw_energy ? &log_energy : NULL));
if (opts_.use_energy && !opts_.raw_energy)
log_energy = log(std::max(VecVec(window, window),
log_energy = Log(std::max(VecVec(window, window),
std::numeric_limits<BaseFloat>::min()));
if (srfft_ != NULL) // Compute FFT using split-radix algorithm.
......
......@@ -162,6 +162,7 @@ int main() {
}
return 0;
} catch (const std::exception &e) {
static_cast<void>(e);
return 1;
}
......
......@@ -27,7 +27,7 @@ namespace kaldi {
Spectrogram::Spectrogram(const SpectrogramOptions &opts)
: opts_(opts), feature_window_function_(opts.frame_opts), srfft_(NULL) {
if (opts.energy_floor > 0.0)
log_energy_floor_ = log(opts.energy_floor);
log_energy_floor_ = Log(opts.energy_floor);
int32 padded_window_size = opts.frame_opts.PaddedWindowSize();
if ((padded_window_size & (padded_window_size-1)) == 0) // Is a power of two
......@@ -68,7 +68,7 @@ void Spectrogram::Compute(const VectorBase<BaseFloat> &wave,
// Compute energy after window function (not the raw one)
if (!opts_.raw_energy)
log_energy = log(std::max(VecVec(window, window),
log_energy = Log(std::max(VecVec(window, window),
std::numeric_limits<BaseFloat>::min()));
if (srfft_ != NULL) // Compute FFT using split-radix algorithm.
......
......@@ -70,6 +70,7 @@ bool RandomSplit(int32 wav_dim,
int32 num_pieces,
int32 trials = 5) {
piece_dim->clear();
piece_dim->resize(num_pieces, 0);
int32 dim_mean = wav_dim / (num_pieces * 2);
int32 cnt = 0;
......@@ -182,7 +183,8 @@ void TestOnlineMfcc() {
// we try to break it into from 5 pieces to 9(not essential to do so)
for (int32 num_piece = 5; num_piece < 10; num_piece++) {
OnlineMfcc online_mfcc(op);
std::vector<int32> piece_length(num_piece);
std::vector<int32> piece_length(num_piece, 0);
bool ret = RandomSplit(waveform.Dim(), &piece_length, num_piece);
KALDI_ASSERT(ret);
......
......@@ -77,10 +77,10 @@ BaseFloat NccfToPov(BaseFloat n) {
BaseFloat ndash = fabs(n);
if (ndash > 1.0) ndash = 1.0; // just in case it was slightly outside [-1, 1]
BaseFloat r = -5.2 + 5.4 * exp(7.5 * (ndash - 1.0)) + 4.8 * ndash -
2.0 * exp(-10.0 * ndash) + 4.2 * exp(20.0 * (ndash - 1.0));
BaseFloat r = -5.2 + 5.4 * Exp(7.5 * (ndash - 1.0)) + 4.8 * ndash -
2.0 * Exp(-10.0 * ndash) + 4.2 * Exp(20.0 * (ndash - 1.0));
// r is the approximate log-prob-ratio of voicing, log(p/(1-p)).
BaseFloat p = 1.0 / (1 + exp(-1.0 * r));
BaseFloat p = 1.0 / (1 + Exp(-1.0 * r));
KALDI_ASSERT(p - p == 0); // Check for NaN/inf
return p;
}
......@@ -210,7 +210,7 @@ class PitchFrameInfo {
/// info for the final state; the iterator will be decremented inside this
/// function.
void SetBestState(int32 best_state,
std::vector<std::pair<int32, BaseFloat> >::iterator lag_nccf_iter);
std::vector<std::pair<int32, BaseFloat> > &lag_nccf);
/// This function may be called on the last (most recent) PitchFrameInfo
/// object; it computes how many frames of latency there is because the
......@@ -313,7 +313,7 @@ void PitchFrameInfo::ComputeBacktraces(
Vector<BaseFloat> local_cost(num_states, kUndefined);
ComputeLocalCost(nccf_pitch, lags, opts, &local_cost);
const BaseFloat delta_pitch_sq = pow(log(1.0 + opts.delta_pitch), 2.0),
const BaseFloat delta_pitch_sq = pow(Log(1.0 + opts.delta_pitch), 2.0),
inter_frame_factor = delta_pitch_sq * opts.penalty_factor;
// index local_cost, prev_forward_cost and this_forward_cost using raw pointer
......@@ -483,10 +483,14 @@ void PitchFrameInfo::ComputeBacktraces(
void PitchFrameInfo::SetBestState(
int32 best_state,
std::vector<std::pair<int32, BaseFloat> >::iterator iter) {
std::vector<std::pair<int32, BaseFloat> > &lag_nccf) {
// This function would naturally be recursive, but we have coded this to avoid
// recursion, which would otherwise eat up the stack. Think of it as a static
// member function, except we do use "this" right at the beginning.
std::vector<std::pair<int32, BaseFloat> >::reverse_iterator iter = lag_nccf.rbegin();
PitchFrameInfo *this_info = this; // it will change in the loop.
while (this_info != NULL) {
PitchFrameInfo *prev_info = this_info->prev_info_;
......@@ -501,7 +505,7 @@ void PitchFrameInfo::SetBestState(
if (prev_info != NULL) // don't write anything for frame -1.
iter->second = this_info->state_info_[state_info_index].pov_nccf;
this_info = prev_info;
iter--;
if (this_info != NULL) ++iter;
}
}
......@@ -989,9 +993,7 @@ void OnlinePitchFeatureImpl::RecomputeBacktraces() {
if (lag_nccf_.size() != static_cast<size_t>(num_frames))
lag_nccf_.resize(num_frames);
std::vector<std::pair<int32, BaseFloat> >::iterator last_iter =
lag_nccf_.end() - 1;
frame_info_.back()->SetBestState(best_final_state, last_iter);
frame_info_.back()->SetBestState(best_final_state, lag_nccf_);
frames_latency_ =
frame_info_.back()->ComputeLatency(opts_.max_frames_latency);
for (size_t i = 0; i < nccf_info_.size(); i++)
......@@ -1146,9 +1148,7 @@ void OnlinePitchFeatureImpl::AcceptWaveform(
int32 best_final_state;
forward_cost_.Min(&best_final_state);
lag_nccf_.resize(frame_info_.size() - 1); // will keep any existing data.
std::vector<std::pair<int32, BaseFloat> >::iterator last_iter =
lag_nccf_.end() - 1;
frame_info_.back()->SetBestState(best_final_state, last_iter);
frame_info_.back()->SetBestState(best_final_state, lag_nccf_);
frames_latency_ =
frame_info_.back()->ComputeLatency(opts_.max_frames_latency);
KALDI_VLOG(4) << "Latency is " << frames_latency_;
......@@ -1425,7 +1425,7 @@ BaseFloat OnlineProcessPitch::GetRawLogPitchFeature(int32 frame) const {
src_->GetFrame(frame, &tmp);
BaseFloat pitch = tmp(1);
KALDI_ASSERT(pitch > 0);
return log(pitch);
return Log(pitch);
}
BaseFloat OnlineProcessPitch::GetNormalizedLogPitchFeature(int32 frame) {
......@@ -1487,7 +1487,7 @@ void OnlineProcessPitch::UpdateNormalizationStats(int32 frame) {
Vector<BaseFloat> tmp(kRawFeatureDim);
src_->GetFrame(prev_window_begin, &tmp);
BaseFloat accurate_pov = NccfToPov(tmp(0)),
log_pitch = log(tmp(1));
log_pitch = Log(tmp(1));
this_stats.sum_pov -= accurate_pov;
this_stats.sum_log_pitch_pov -= accurate_pov * log_pitch;
}
......@@ -1496,7 +1496,7 @@ void OnlineProcessPitch::UpdateNormalizationStats(int32 frame) {
Vector<BaseFloat> tmp(kRawFeatureDim);
src_->GetFrame(prev_window_end, &tmp);
BaseFloat accurate_pov = NccfToPov(tmp(0)),
log_pitch = log(tmp(1));
log_pitch = Log(tmp(1));
this_stats.sum_pov += accurate_pov;
this_stats.sum_log_pitch_pov += accurate_pov * log_pitch;
}
......@@ -1515,7 +1515,7 @@ void OnlineProcessPitch::UpdateNormalizationStats(int32 frame) {
for (int32 f = this_window_begin; f < this_window_end; f++) {
src_->GetFrame(f, &tmp);
BaseFloat accurate_pov = NccfToPov(tmp(0)),
log_pitch = log(tmp(1));
log_pitch = Log(tmp(1));
this_stats.sum_pov += accurate_pov;
this_stats.sum_log_pitch_pov += accurate_pov * log_pitch;
}
......
......@@ -133,7 +133,7 @@ void UnitTestArbitraryResample() {
if (num_zeros == 3) {
KALDI_ASSERT(error < 0.1);
} else {
KALDI_ASSERT(error < 0.02);
KALDI_ASSERT(error < 0.025);
}
} else {
KALDI_VLOG(1) << "[not checking since out of bounds]";
......@@ -225,7 +225,7 @@ void UnitTestLinearResample() {
}
void UnitTestLinearResample2() {
int32 num_samp = 100 + rand() % 100;
int32 num_samp = 150 + rand() % 100;
BaseFloat samp_freq = 1000, resamp_freq = 4000;
int32 num_zeros = 10; // fairly accurate.
......@@ -257,7 +257,7 @@ void UnitTestLinearResample2() {
linear_resampler2.Resample(signal_upsampled, true, &signal_downsampled);
int32 samp_discard = 20; // Discard 20 samples for edge effects.
int32 samp_discard = 30; // Discard 20 samples for edge effects.
SubVector<BaseFloat> signal_middle(signal, samp_discard,
signal.Dim() - (2 * samp_discard));
......
Markdown is supported
0% </