48 #ifndef KALDI_FEAT_WAVE_READER_H_ 49 #define KALDI_FEAT_WAVE_READER_H_ 96 void Read(std::istream &is);
116 void Read(std::istream &is);
119 void Write(std::ostream &os)
const;
147 static const uint32 kBlockSize = 1024 * 1024;
162 static bool Write(std::ostream &os,
bool binary,
const T &t) {
165 KALDI_ERR <<
"Wave data can only be written in binary mode.";
169 }
catch (
const std::exception &e) {
170 KALDI_WARN <<
"Exception caught in WaveHolder object (writing). " 175 void Copy(
const T &t) { t_.CopyFrom(t); }
184 t_.CopyFrom(other.
t_);
196 }
catch (
const std::exception &e) {
197 KALDI_WARN <<
"Exception caught in WaveHolder::Read(). " << e.what();
203 t_.Swap(&(other->
t_));
207 KALDI_ERR <<
"ExtractRange is not defined for this type of holder.";
230 }
catch (
const std::exception &e) {
231 KALDI_WARN <<
"Exception caught in WaveInfoHolder::Read(). " << e.what();
237 KALDI_ERR <<
"ExtractRange is not defined for this type of holder.";
248 #endif // KALDI_FEAT_WAVE_READER_H_ int32 NumChannels() const
Number of channels, 1 to 16.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool Read(std::istream &is)
size_t DataBytes() const
Wave data bytes. Invalid if IsStreamed() is true.
uint32 SampleCount() const
Number of samples in stream. Invalid if IsStreamed() is true.
Base class which provides matrix operations not involving resizing or allocation. ...
void Swap(WaveData *other)
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
bool ReverseBytes() const
Is data file byte order different from machine byte order?
BaseFloat Duration() const
Approximate duration, seconds. Invalid if IsStreamed() is true.
BaseFloat SampFreq() const
const Matrix< BaseFloat > & Data() const
bool ExtractRange(const WaveHolder &other, const std::string &range)
static bool IsReadInBinary()
bool IsStreamed() const
Is stream size unknown? Duration and SampleCount not valid if true.
Matrix< BaseFloat > data_
void Read(std::istream &is)
'is' should be opened in binary mode.
void Swap(WaveHolder *other)
void Swap(WaveInfoHolder *other)
This class reads and hold wave file header information.
const BaseFloat kWaveSampleMax
For historical reasons, we scale waveforms to the range (2^15-1)*[-1, 1], not the usual default DSP r...
void CopyFrom(const WaveData &other)
WaveData(BaseFloat samp_freq, const MatrixBase< BaseFloat > &data)
bool Read(std::istream &is)
This class's purpose is to read in Wave files.
static bool IsReadInBinary()
BaseFloat Duration() const
BaseFloat SampFreq() const
Sample frequency, Hz.
void Write(std::ostream &os) const
Write() will throw on error. os should be opened in binary mode.
static bool Write(std::ostream &os, bool binary, const T &t)
WaveHolder(const WaveHolder &other)
bool ExtractRange(const WaveInfoHolder &other, const std::string &range)
size_t BlockAlign() const
Bytes per sample.