|
PebbleOS
|
Validation and traversal of serialized transcriptions received from the phone. More...
Data Structures | |
| struct | TranscriptionWord |
| Word with its confidence value. More... | |
| struct | TranscriptionSentence |
| Sentence, a serialized list of words. More... | |
| struct | Transcription |
| Transcription: one or more sentences of words. More... | |
Typedefs | |
| typedef bool(* | TranscriptionSentenceIterateCb) (const TranscriptionSentence *sentence, void *data) |
| Sentence iteration callback. | |
| typedef bool(* | TranscriptionWordIterateCb) (const TranscriptionWord *word, void *data) |
| Word iteration callback. | |
Enumerations | |
| enum | TranscriptionType { TranscriptionTypeSentenceList = 0x01 } |
| Transcription format. More... | |
Functions | |
| bool | transcription_validate (const Transcription *transcription, size_t size) |
| Check that a transcription received from the phone is well formed. | |
| void * | transcription_iterate_sentences (const TranscriptionSentence *sentences, size_t count, TranscriptionSentenceIterateCb handle_sentence, void *data) |
| Iterate over a serialized list of sentences. | |
| void * | transcription_iterate_words (const TranscriptionWord *words, size_t count, TranscriptionWordIterateCb handle_word, void *data) |
| Iterate over a serialized list of words. | |
Validation and traversal of serialized transcriptions received from the phone.
A transcription is kept in memory exactly as received over the voice endpoint: packed, variable-length sentences, each a list of variable-length words.
| struct TranscriptionWord |
Word with its confidence value.
| Data Fields | ||
|---|---|---|
| uint8_t | confidence | Confidence in percent (1-100), or 0 if not available. |
| utf8_t | data[] | UTF-8 text, not zero terminated. |
| uint16_t | length | Length of data in bytes. |
| struct TranscriptionSentence |
Sentence, a serialized list of words.
| Data Fields | ||
|---|---|---|
| uint16_t | word_count | Number of words. |
| TranscriptionWord | words[] | Serialized words; use transcription_iterate_words() as they have variable length. |
| struct Transcription |
Transcription: one or more sentences of words.
Not all recognizers produce several sentences or per-word confidence; the simplest transcription is a single sentence with all confidence values set to 0.
| Data Fields | ||
|---|---|---|
| uint8_t | sentence_count | Number of sentences. |
| TranscriptionSentence | sentences[] | Serialized sentences; use transcription_iterate_sentences() as they have variable length. |
| TranscriptionType | type: 8 | Format of the transcription. |
| typedef bool(* TranscriptionSentenceIterateCb) (const TranscriptionSentence *sentence, void *data) |
Sentence iteration callback.
| sentence | Current sentence. |
| data | Context pointer. |
| typedef bool(* TranscriptionWordIterateCb) (const TranscriptionWord *word, void *data) |
Word iteration callback.
| word | Current word. |
| data | Context pointer. |
| enum TranscriptionType |
Transcription format.
| Enumerator | |
|---|---|
| TranscriptionTypeSentenceList | List of sentences, the only supported format. |
| void * transcription_iterate_sentences | ( | const TranscriptionSentence * | sentences, |
| size_t | count, | ||
| TranscriptionSentenceIterateCb | handle_sentence, | ||
| void * | data | ||
| ) |
Iterate over a serialized list of sentences.
| sentences | First sentence. |
| count | Number of sentences. |
| handle_sentence | Callback for each sentence, may be NULL to only skip over the list. |
| data | Context pointer passed to handle_sentence. |
| void * transcription_iterate_words | ( | const TranscriptionWord * | words, |
| size_t | count, | ||
| TranscriptionWordIterateCb | handle_word, | ||
| void * | data | ||
| ) |
Iterate over a serialized list of words.
| words | First word. |
| count | Number of words. |
| handle_word | Callback for each word, may be NULL to only skip over the list. |
| data | Context pointer passed to handle_word. |
| bool transcription_validate | ( | const Transcription * | transcription, |
| size_t | size | ||
| ) |
Check that a transcription received from the phone is well formed.
The format must be supported, every sentence and word non-empty, words free of control characters other than backspace, and the content must exactly fill size bytes.
| transcription | Transcription to check, may be NULL. |
| size | Size of the received buffer in bytes. |