refr has a really nice and simple to use gzip stream implementation. It is possible to zip several OpenFst FSTs togeather (or anything else) and read them using the following snippet.

#include <fst/fstlib.h>
#include <iostream>
#include "gzstream.h"

using namespace std;
using namespace fst;

int main() {
  igzstream strm("fsts.gz");
  StdFst* fst1 = StdFst::Read(strm, FstReadOptions());
  cout << "# of states " << CountStates(*fst) << endl;
  //Read some more fsts from the same stream
  return 0;

Extract the gzstream.{C,h} files and to build on OSX 10.9 (remove the stdlib flag for other compilers/platforms)

   g++ -O2 -o read gzstream.C test.cc -I/usr/local/include/ -stdlib=libstdc++ -lz -lfst

This entry was posted by Unknown. Bookmark the permalink.

9 thoughts on “gzstreamfst.md”

Leave a Reply

Note: only a member of this blog may post a comment.