SUtterance([voice = None])
The Utterance class. An Utterance consists of a set of relations, which in turn consists of a set of items.
Initialize a newly created utterance for the given voice.
Parameters: | voice (SVoice) – The voice associated with this utterance. |
---|---|
Returns: | Newly created utterance object |
Return type: | SUtterance |
Raises : | RuntimeError if Speect was unable to create the utterance. |
Note
The utterance is deleted when the SUtterance object is deleted.
Note
The SUtterance object inherits from SObject in the Speect Engine and can therefore be used in functions/methods that require parameters of type SObject
SUtterance.relation_new(name) | Create a new named relation in the utterance. |
SUtterance.relation_get(name) | Get the named relation from the utterance. |
SUtterance.relation_set(rel) | Set the given relation in the utterance. |
SUtterance.relation_del(name) | Delete the relation with the given name from the utterance. |
SUtterance.features | Get the features that are defined for the utterance processor. |
SUtterance.voice | Get or set an utterance’s voice attribute (the voice that is associated with the utterance). |
Methods relating to the utterance’s relations:
relation_new(name)
Create a new named relation in the utterance. Creates a relation, initializes it, and sets it in the utterance.
Parameters: | name (str) – The name of the new relation to create. |
---|---|
Returns: | Newly created relation object |
Return type: | SRelation |
Raises : | RuntimeError if Speect was unable to create the relation. |
Note : | If a relation with the given name already exists in the utterance, then it will be deleted. |
relation_get(name)
Get the named relation from the utterance.
Parameters: | name (str) – The name of the relation to get. |
---|---|
Returns: | Named relation, or None if such a relation does not exist in the utterance. |
Return type: | SRelation |
relation_set(rel)
Set the given relation in the utterance.
Parameters: | rel (SRelation) – The relation to set in the utterance. |
---|
relation_del(name)
Delete the relation with the given name from the utterance.
Parameters: | name (str) – The relation to delete from the utterance. |
---|
SUtterance supports the Python method __contains__() , therefore membership type tests for relations can be done:
key in utterance
Return True if utterance has a relation named key, else False.
key not in utterance
Equivalent to not key in utterance.
for key in utterance
SUtterance supports the Python iterator protocol and therefore one can iterate over a relation names (key) in the utterance.
An utterance has features which can be accessed by:
Get the features that are defined for the utterance.
Returns: | A map of the utterance features. |
---|---|
Return type: | SMap |
For example:
input_type = utterance.features["input"]
See SMap for the implemented operations.
str(utterance)
SUtterance supports the Python method __str__() and can therefore be used in the str() built-in function and by the print statement to compute the “informal” string representation of the utterance.