Introduction
A finite-state transducer is a graph that turns one sequence of symbols into another: the states are joined by arcs that read an input symbol, write an output symbol and carry a weight. Speech recognition and text processing use them for pronunciation lexicons and language models. The OpenFst library saves them in a binary file, usually with the extension .fst.
The format here was checked on eight files, the pmap.*.fst pronunciation
maps in macOS’s SpeechRecognitionSharedSupport.framework: the header,
the two symbol tables and the one state with its arcs. All eight are the vector type with
standard arcs, so other types (const, compact and so on) are not described, and the
page is marked partial.
The extension is shared with FL Studio presets, which start with “FLhd”, and with F* source files, which are text. The first four bytes tell them apart.
Structure
Everything is little-endian. A string is a 4-byte length and then that many bytes, with no terminator.
| Offset | Size | Field | In the files seen |
|---|---|---|---|
| 0 | 4 | Magic, D6 FD B2 7E (0x7EB2FDD6) | always |
| 4 | 4 + n | FST type, a string | vector (n = 6) |
| 14 | 4 + n | Arc type, a string | standard (n = 8): tropical weights |
| 26 | 4 | Version | 2 |
| 30 | 4 | Flags: bit 0 an input symbol table follows, bit 1 an output one | 3 |
| 34 | 8 | Properties, a bitmap of facts about the transducer | 0x8115820003 |
| 42 | 8 | Start state | 0 |
| 50 | 8 | Number of states | 1 |
| 58 | 8 | Number of arcs | 0 in all eight files, though they hold 1,519 to 2,914 arcs; read the count in each state |
| 66 | varies | Input symbol table, if flag bit 0 is set | present |
| then | varies | Output symbol table, if flag bit 1 is set | present |
| then | varies | The states (vector type) | one state with all the arcs |
In the vector type each state is a final weight (4-byte float; 0 in these files), an arc
count (8 bytes) and then that many 16-byte arcs: input label, output label (both 4 bytes,
0 is epsilon), weight (4-byte float) and next state (4 bytes). The eight files have one
state, and every arc leads back to state 0: the transducer maps phoneme symbols to
output symbols with a cost, for example the second arc of pmap.en_GB.fst
is input 0, output 2, weight 4.0215.
A symbol table is the magic 74 FB B2 7E (0x7EB2FB74), the table’s name
as a string, the next free key (8 bytes), the number of symbols (8 bytes), then each
symbol as a string followed by its key (8 bytes). In the macOS files the name is a path
from the vendor’s build, the tables have 38 to 55 symbols that begin
<eps> (key 0), AA, AE, AH in the English files, and the output table
has two more symbols than the input table in every file.
Worked example
00000000 d6 fd b2 7e magic
00000004 06 00 00 00 76 65 63 74 6f 72 "vector"
0000000e 08 00 00 00 73 74 61 6e 64 61 72 64 "standard"
0000001a 02 00 00 00 03 00 00 00 version 2, flags 3
00000022 03 00 82 15 81 00 00 00 properties
0000002a 00..(8) 01 00..(8) 00..(8) start 0, 1 state, 0 arcs
00000042 74 fb b2 7e 56 00 00 00 2f 61 6d 72 ... symbol table, name of 86 bytes
Not described
This page is partial. It rests on eight files that are all the vector type with standard arcs and one state.
| Item | Reference | Viewer |
|---|---|---|
| Other FST types (const, compact and so on) | Not described. | Shows the states as bytes. |
| Other arc types and weights | Not described; only “standard” (float weights) was seen. | Shows the states as bytes. |
| Files with more than one state | The per-state layout is described, but none was seen with more than one state. | Reads them the same way; unchecked. |
| Properties bitmap | The meaning of the bits is not given. | Shows the number in hex. |
| Header arc count | It is 0 in all eight files although the state holds arcs; why is not known. | Shows the header value and the counted arcs separately. |
| Tables of more than 2,000 symbols or arcs | Not applicable. | The Arcs and symbol tables list the first 2,000 rows; the tree holds all. |
| Version other than 2, flags other than 3 | Not seen; the flag bits 2 and 3 (aligned, mapped) are named from memory. | Reads the symbol tables by flag bits 0 and 1 only. |
Also used for
- FL Studio channel preset – File type 32: one channel of the channel rack, with its sample or plugin.
- FL Studio mixer preset – File type 64: one mixer insert, with its effect plugin and its settings.
- FL Studio plugin preset – File type 48: one plugin’s name and saved state, with no channel around it.
- FL Studio preset – FL Studio channel, plugin and mixer presets: an FLP file with another file type.
Links
Software
- OpenFst – library and command-line tools for weighted finite-state transducers (C++)