Viterbi history structures. More...
#include <stdio.h>#include <ngram_model.h>#include <cmd_ln.h>#include <logmath.h>#include <glist.h>#include "s3types.h"#include "fillpen.h"#include "s3dict.h"#include "dict2pid.h"Go to the source code of this file.
Data Structures | |
| union | vh_lmstate_u |
| LM state. More... | |
| struct | backpointer_s |
| struct | vithist_entry_t |
| Viterbi history entry. More... | |
| struct | vh_lms2vh_t |
| In each frame, there are several word exits. More... | |
| struct | vithist_t |
| Memory management of Viterbi history entries done in blocks. More... | |
Defines | |
| #define | vithist_entry_wid(ve) ((ve)->wid) |
| Return the word ID of an entry. | |
| #define | vithist_entry_sf(ve) ((ve)->sf) |
| Return the starting frame of an entry. | |
| #define | vithist_entry_ef(ve) ((ve)->ef) |
| Return the ending frame of an entry. | |
| #define | vithist_entry_ascr(ve) ((ve)->ascr) |
| Return the acoustic score of an entry. | |
| #define | vithist_entry_lscr(ve) ((ve)->lscr) |
| Return the language score of an entry. | |
| #define | vithist_entry_score(ve) ((ve)->path.score) |
| Return the total score of an entry. | |
| #define | vithist_entry_pred(ve) ((ve)->path.pred) |
| #define | vithist_entry_valid(ve) ((ve)->valid) |
| #define | VITHIST_BLKSIZE 16384 |
| #define | VITHIST_MAXBLKS 256 |
| #define | VITHIST_ID2BLK(i) ((i) >> 14) |
| #define | VITHIST_ID2BLKOFFSET(i) ((i) & 0x00003fff) |
| #define | vithist_id2entry(vh, id) ((vh)->entry[VITHIST_ID2BLK(id)] + VITHIST_ID2BLKOFFSET(id)) |
| Access macros; not meant for arbitrary use. | |
| #define | vithist_n_entry(vh) ((vh)->n_entry) |
| Return the number of entry in the Viterbi history. | |
| #define | vithist_bestscore(vh) ((vh)->bestscore) |
| Return the best score of the Viterbi history. | |
| #define | vithist_bestvh(vh) ((vh)->bestvh) |
| Return the best viterbi history entry ID of the Viterbi history. | |
| #define | vithist_lms2vh_root(vh, w) ((vh)->lms2vh_root[w]) |
| Return lms2vh. | |
| #define | vithist_lwidlist(vh) ((vh)->lwidlist) |
| Return the language word ID list. | |
| #define | vithist_first_entry(vh, f) ((vh)->frame_start[f]) |
| Return the first entry for the frame f. | |
| #define | vithist_last_entry(vh, f) ((vh)->frame_start[f+1] - 1) |
| Return the last entry for the frame f. | |
Typedefs | |
| typedef union vh_lmstate_u | vh_lmstate_t |
| LM state. | |
| typedef struct backpointer_s | backpointer_t |
Functions | |
| vithist_t * | vithist_init (int32 lm_nword, int32 n_ci, int32 wbeam, int32 bghist, int32 report) |
| One-time intialization: Allocate and return an initially empty vithist module. | |
| int32 | vithist_utt_begin (vithist_t *vh, int32 wid, int32 lwid) |
| Invoked at the beginning of each utterance; vithist initialized with a root <s> entry. | |
| int32 | vithist_utt_end (vithist_t *vh, ngram_model_t *lm, s3dict_t *dict, dict2pid_t *dict2pid, fillpen_t *fp) |
| Invoked at the end of each utterance; append a final </s> entry that results in the best path score (i.e., LM including LM transition to </s>). | |
| int32 | vithist_partialutt_end (vithist_t *vh, ngram_model_t *lm, s3dict_t *dict) |
| Invoked at the end of each block of a live decode. | |
| void | vithist_utt_reset (vithist_t *vh) |
| glist_t | vithist_backtrace (vithist_t *vh, int32 id, s3dict_t *dict) |
| Viterbi backtrace. | |
| void | vithist_enter (vithist_t *vh, s3dict_t *dict, dict2pid_t *dict2pid, vithist_entry_t *tve, int32 comp_rc) |
| Add an entry to the Viterbi history table without rescoring. | |
| void | vithist_rescore (vithist_t *vh, ngram_model_t *lm, s3dict_t *dict, dict2pid_t *dict2pid, fillpen_t *fp, s3wid_t wid, int32 ef, int32 score, int32 pred, int32 type, int32 rc) |
| Like vithist_enter, but LM-rescore this word exit wrt all histories that ended at the same time as the given, tentative pred. | |
| void | vithist_frame_windup (vithist_t *vh, int32 frm, FILE *fp, ngram_model_t *lm, s3dict_t *dict) |
| Invoked at the end of each frame. | |
| void | vithist_prune (vithist_t *vh, s3dict_t *dict, int32 frm, int32 maxwpf, int32 maxhist, int32 beam) |
| Mark up to maxwpf best words, and variants within beam of best frame score as valid, and the remaining as invalid. | |
| void | vithist_dump (vithist_t *vh, int32 frm, ngram_model_t *lm, s3dict_t *dict, FILE *fp) |
| Dump the Viterbi history data to the given file (for debugging/diagnostics). | |
| void | vithist_free (vithist_t *vh) |
| Free a Viterbi history data structure. | |
| void | vithist_report (vithist_t *vh) |
| Report a Viterbi history architecture. | |
| void | vh_lmstate_display (vh_lmstate_t *vhl, s3dict_t *dict) |
| Display the lmstate of an entry. | |
| void | vithist_entry_display (vithist_entry_t *ve, s3dict_t *dict) |
| Display the vithist_entry structure. | |
Viterbi history structures.
Mainly vithist_t, also its slightly older brother latticehist_t. They are respectively used by decode (mode 4 and 5) and decode_anytopo (mode 3). The curent arrangement is temporary.
Definition in file vithist.h.
| #define vithist_id2entry | ( | vh, | |||
| id | ) | ((vh)->entry[VITHIST_ID2BLK(id)] + VITHIST_ID2BLKOFFSET(id)) |
Access macros; not meant for arbitrary use.
Return a pointer to the entry with the given ID.
Definition at line 267 of file vithist.h.
Referenced by vithist_dump(), vithist_enter(), vithist_partialutt_end(), vithist_prune(), vithist_rescore(), and vithist_utt_end().
| typedef union vh_lmstate_u vh_lmstate_t |
LM state.
Depending on type of LM (word-ngram, class-ngram, FSG, etc.), the contents of LM state will vary. Accommodate them with a union. For now, only trigram LM in it. (Not completely thought out; some of this might have to change later.)
| void vh_lmstate_display | ( | vh_lmstate_t * | vhl, | |
| s3dict_t * | dict | |||
| ) |
Display the lmstate of an entry.
| vhl | In: An lmstate data structure | |
| dict | In: If specified, the word string of lm IDs would also be translated |
Definition at line 134 of file vithist.c.
References vh_lmstate_u::lwid.
Viterbi backtrace.
Return value: List of hyp_t pointer entries for the individual word segments. Caller responsible for freeing the list.
| vh | In: a Viterbi history data structure | |
| id | ID from which to begin backtrace | |
| dict | a dictionary for look up the ci phone of a word |
Dump the Viterbi history data to the given file (for debugging/diagnostics).
| vh | In: a Viterbi history data structure | |
| frm | In: If >= 0, print only entries made in this frame, otherwise print all entries | |
| lm | In: Language model | |
| dict | In: Dictionary | |
| fp | Out: File to be written |
Definition at line 943 of file vithist.c.
References vithist_entry_t::ascr, vithist_t::bestscore, vithist_t::bestvh, vithist_entry_t::ef, vithist_t::frame_start, vithist_entry_t::lmstate, vithist_entry_t::lscr, vh_lmstate_u::lwid, vithist_t::n_entry, vithist_t::n_frm, vithist_entry_t::path, vithist_entry_t::type, vithist_entry_t::valid, vithist_id2entry, and vithist_entry_t::wid.
| void vithist_enter | ( | vithist_t * | vh, | |
| s3dict_t * | dict, | |||
| dict2pid_t * | dict2pid, | |||
| vithist_entry_t * | tve, | |||
| int32 | comp_rc | |||
| ) |
Add an entry to the Viterbi history table without rescoring.
Any entry having the same LM state will be replaced with the one given.
| vh | The history table | |
| dict | Dictionary | |
| dict2pid | Context table mapping thing | |
| tve | an input vithist element | |
| comp_rc | a compressed rc. If it is the actual rc, it won't work. FIXME: WHAT DOES THIS MEAN?!!?!? |
Definition at line 376 of file vithist.c.
References vithist_t::bestscore, vithist_t::bestvh, get_rc_nssid(), vithist_entry_t::lmstate, vithist_t::n_ci, vithist_t::n_entry, vithist_t::n_frm, vithist_entry_t::n_rc, vithist_entry_t::path, vithist_entry_t::rc, vithist_id2entry, and vithist_entry_t::wid.
| void vithist_entry_display | ( | vithist_entry_t * | ve, | |
| s3dict_t * | dict | |||
| ) |
Display the vithist_entry structure.
| ve | In: An entry of vithist | |
| dict | In: If specified, the word string of lm IDs would also be translated |
Definition at line 143 of file vithist.c.
References vithist_entry_t::ascr, vithist_entry_t::ef, vithist_entry_t::lmstate, vithist_entry_t::lscr, vithist_entry_t::path, vithist_entry_t::type, vithist_entry_t::valid, and vithist_entry_t::wid.
| void vithist_frame_windup | ( | vithist_t * | vh, | |
| int32 | frm, | |||
| FILE * | fp, | |||
| ngram_model_t * | lm, | |||
| s3dict_t * | dict | |||
| ) |
Invoked at the end of each frame.
| vh | In/Out: Vithist module to be updated | |
| frm | In: Frame in which being invoked | |
| fp | In: If not NULL, dump vithist entries this frame to the file (for debugging) | |
| lm | In: Language model | |
| dict | In: Dictionary |
Definition at line 760 of file vithist.c.
References vithist_t::bestscore, vithist_t::bestvh, vithist_t::frame_start, vithist_t::n_entry, and vithist_t::n_frm.
| void vithist_free | ( | vithist_t * | vh | ) |
Free a Viterbi history data structure.
| vh | In: a Viterbi history data structure |
Definition at line 998 of file vithist.c.
References vithist_t::bestscore, vithist_t::bestvh, vithist_t::entry, vithist_t::frame_start, and vithist_t::lms2vh_root.
| vithist_t* vithist_init | ( | int32 | lm_nword, | |
| int32 | n_ci, | |||
| int32 | wbeam, | |||
| int32 | bghist, | |||
| int32 | report | |||
| ) |
One-time intialization: Allocate and return an initially empty vithist module.
| lm_nword | Number of words in language model | |
| n_ci | Number of CI phones | |
| wbeam | Word exit beam width | |
| bghist | If only bigram history is used | |
| report | Whether to report the progress |
Definition at line 156 of file vithist.c.
References vithist_t::bestscore, vithist_t::bestvh, vithist_t::bghist, vithist_t::entry, vithist_t::frame_start, vithist_t::lms2vh_root, vithist_t::lwidlist, vithist_t::n_ci, vithist_t::n_entry, and vithist_t::wbeam.
Invoked at the end of each block of a live decode.
Returns viterbi histories of partial decodes
| vh | In: a Viterbi history data structure |
Definition at line 869 of file vithist.c.
References vithist_t::frame_start, vithist_entry_t::lmstate, vh_lmstate_u::lwid, vithist_t::n_frm, vithist_entry_t::path, and vithist_id2entry.
| void vithist_prune | ( | vithist_t * | vh, | |
| s3dict_t * | dict, | |||
| int32 | frm, | |||
| int32 | maxwpf, | |||
| int32 | maxhist, | |||
| int32 | beam | |||
| ) |
Mark up to maxwpf best words, and variants within beam of best frame score as valid, and the remaining as invalid.
| vh | In: a Viterbi history data structure | |
| dict | In: Dictionary, for distinguishing filler words | |
| frm | In: Frame in which being invoked | |
| maxwpf | In: Max unique words per frame to be kept valid | |
| maxhist | In: Max histories to maintain per frame | |
| beam | In: Entry score must be >= frame bestscore+beam |
Definition at line 656 of file vithist.c.
References BAD_S3WID, vithist_t::bestscore, vithist_t::bghist, vithist_t::frame_start, vithist_t::n_entry, vithist_entry_t::path, vithist_entry_t::valid, vithist_id2entry, and vithist_entry_t::wid.
| void vithist_report | ( | vithist_t * | vh | ) |
Report a Viterbi history architecture.
| vh | In: a Viterbi history data structure |
Definition at line 1026 of file vithist.c.
References vithist_t::bghist, and vithist_t::wbeam.
| void vithist_rescore | ( | vithist_t * | vh, | |
| ngram_model_t * | lm, | |||
| s3dict_t * | dict, | |||
| dict2pid_t * | dict2pid, | |||
| fillpen_t * | fp, | |||
| s3wid_t | wid, | |||
| int32 | ef, | |||
| int32 | score, | |||
| int32 | pred, | |||
| int32 | type, | |||
| int32 | rc | |||
| ) |
Like vithist_enter, but LM-rescore this word exit wrt all histories that ended at the same time as the given, tentative pred.
Create a new vithist entry for each predecessor (but, of course, only the best for each distinct LM state will be retained; see above).
ARCHAN: Precisely speaking, it is a full trigram rescoring.
| vh | In: a Viterbi history data structure | |
| lm | In: Language model | |
| dict | In: Dictionary | |
| dict2pid | Context table mapping thing | |
| fp | In: Filler penalty list | |
| wid | In: a dictionary word ID | |
| ef | In: End frame for this word instance | |
| score | In: Does not include LM score for this entry | |
| pred | In: Tentative predecessor | |
| type | In: Type of lexical tree | |
| rc | In: The compressed rc. So if you use the actual rc, it doesn't work. |
Definition at line 470 of file vithist.c.
References vithist_entry_t::ascr, vithist_t::bestscore, vithist_entry_t::ef, tst_search_s::fillpen, vithist_t::frame_start, vithist_entry_t::lmstate, vithist_entry_t::lscr, vh_lmstate_u::lwid, vithist_t::n_frm, vithist_entry_t::n_rc, vithist_entry_t::path, vithist_entry_t::rc, vithist_entry_t::type, vithist_entry_t::valid, vithist_id2entry, vithist_t::wbeam, and vithist_entry_t::wid.
| int32 vithist_utt_begin | ( | vithist_t * | vh, | |
| int32 | wid, | |||
| int32 | lwid | |||
| ) |
Invoked at the beginning of each utterance; vithist initialized with a root <s> entry.
| vh | In: a Viterbi history data structure | |
| wid | In: dictionary ID of start word | |
| lwid | In: language model ID of start word |
Definition at line 284 of file vithist.c.
References vithist_entry_t::ascr, vithist_t::bestscore, vithist_t::bestvh, vithist_entry_t::ef, vithist_t::entry, vithist_t::frame_start, vithist_entry_t::lmstate, vithist_entry_t::lscr, vh_lmstate_u::lwid, vithist_t::lwidlist, vithist_t::n_entry, vithist_t::n_frm, vithist_entry_t::path, vithist_entry_t::type, vithist_entry_t::valid, and vithist_entry_t::wid.
| int32 vithist_utt_end | ( | vithist_t * | vh, | |
| ngram_model_t * | lm, | |||
| s3dict_t * | dict, | |||
| dict2pid_t * | dict2pid, | |||
| fillpen_t * | fp | |||
| ) |
Invoked at the end of each utterance; append a final </s> entry that results in the best path score (i.e., LM including LM transition to </s>).
Return the ID of the appended entry if successful, -ve if error (empty utterance).
| vh | In: a Viterbi history data structure |
Definition at line 779 of file vithist.c.
References vithist_entry_t::ascr, BAD_S3FRMID, vithist_entry_t::ef, vithist_t::frame_start, vithist_entry_t::lmstate, vithist_entry_t::lscr, vh_lmstate_u::lwid, vithist_t::n_entry, vithist_t::n_frm, vithist_entry_t::path, vithist_entry_t::type, vithist_entry_t::valid, vithist_id2entry, and vithist_entry_t::wid.
| void vithist_utt_reset | ( | vithist_t * | vh | ) |
| vh | In: a Viterbi history data structure |
Definition at line 919 of file vithist.c.
References vithist_t::bestscore, vithist_t::bestvh, vithist_t::entry, and vithist_t::n_entry.
1.6.1