I can see that that would be useful.
The main piece of code that that would directly interact with is class
OnlineFeaturePipeline (and wrappers thereof), which has the following
interfaces that are relevant:
void AcceptWaveform(BaseFloat sampling_rate, const
VectorBase<BaseFloat> &waveform);
// InputFinished() tells the class you won't be providing any
// more waveform.
void InputFinished();
Probably a suitable interface would be as follows:
struct PcmStreamReaderOptions {
// format options here.
// Also the chunk size (number of seconds of data to read
// per chunk) could be set here.
};
class PcmStreamReader {
public:
// Constructor. Does not block.
PcmStreamReader(const PcmStreamReaderOptions &opts,
std::istream &is);
// Returns the sampling rate in Hz, as specified in 'opts'.
BaseFloat SamplingRate() const;
// Attempts to read the next chunk of data from the stream.
// May block while reading it. The chunk of data will represent
// a signal of duration not exceeding the chunk size specified
// in the options. It may only be less than the specified chunk
// size if we have reached the end of the input.
// If after reading 'chunk' we have reached the end of the input
// (EOF), 'finished' will be set to true; otherwise it will be set to false.
void ReadNextChunk(Vector<BaseFloat> *chunk,
bool *finished);
private:
...
};
But in general I don't like to check in code that's not used anywhere in Kaldi.
It's not clear to me where we could actually use this. It would be possible
to write a simple decoder that read from just one pcm stream and
decoded online, but that would be very wasteful if you had to run the
program again each time. Writing a server that accepts some kind of
protocol request seems to start to get beyond the core scope of Kaldi,
and I'm concerned about how we would maintain such a thing.
Dan