PebbleOS
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
Transcription

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.
 

Detailed Description

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.

static bool count_word(const TranscriptionWord *word, void *data) {
(*(size_t *)data)++;
return true;
}
if (transcription_validate(t, size)) {
size_t words = 0;
const TranscriptionSentence *s = &t->sentences[0];
transcription_iterate_words(s->words, s->word_count, count_word, &words);
}
TranscriptionWord words[]
Serialized words; use transcription_iterate_words() as they have variable length.
Definition transcription.h:57
uint16_t word_count
Number of words.
Definition transcription.h:55
Sentence, a serialized list of words.
Definition transcription.h:53
Word with its confidence value.
Definition transcription.h:43
void * transcription_iterate_words(const TranscriptionWord *words, size_t count, TranscriptionWordIterateCb handle_word, void *data)
Iterate over a serialized list of words.
bool transcription_validate(const Transcription *transcription, size_t size)
Check that a transcription received from the phone is well formed.

Data Structure Documentation

◆ TranscriptionWord

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.

◆ TranscriptionSentence

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.

◆ Transcription

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 Documentation

◆ TranscriptionSentenceIterateCb

typedef bool(* TranscriptionSentenceIterateCb) (const TranscriptionSentence *sentence, void *data)

Sentence iteration callback.

Parameters
sentenceCurrent sentence.
dataContext pointer.
Returns
true to continue, false to stop the iteration.

◆ TranscriptionWordIterateCb

typedef bool(* TranscriptionWordIterateCb) (const TranscriptionWord *word, void *data)

Word iteration callback.

Parameters
wordCurrent word.
dataContext pointer.
Returns
true to continue, false to stop the iteration.

Enumeration Type Documentation

◆ TranscriptionType

Transcription format.

Enumerator
TranscriptionTypeSentenceList 

List of sentences, the only supported format.

Function Documentation

◆ transcription_iterate_sentences()

void * transcription_iterate_sentences ( const TranscriptionSentence *  sentences,
size_t  count,
TranscriptionSentenceIterateCb  handle_sentence,
void *  data 
)

Iterate over a serialized list of sentences.

Parameters
sentencesFirst sentence.
countNumber of sentences.
handle_sentenceCallback for each sentence, may be NULL to only skip over the list.
dataContext pointer passed to handle_sentence.
Returns
End of the list, or the sentence at which the callback stopped the iteration.

◆ transcription_iterate_words()

void * transcription_iterate_words ( const TranscriptionWord *  words,
size_t  count,
TranscriptionWordIterateCb  handle_word,
void *  data 
)

Iterate over a serialized list of words.

Parameters
wordsFirst word.
countNumber of words.
handle_wordCallback for each word, may be NULL to only skip over the list.
dataContext pointer passed to handle_word.
Returns
End of the list, or the word at which the callback stopped the iteration.

◆ transcription_validate()

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.

Parameters
transcriptionTranscription to check, may be NULL.
sizeSize of the received buffer in bytes.
Returns
true if the transcription is valid.