Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
speaker.py
Go to the documentation of this file.
1 ## @package data_structs.speaker
2 
3 from data_structs.base_objects import BLLObject
4 from db.bll_database import DBConstants
5 
6 ## This class represents a LENA-defined speaker.
7 # Every speaker has a LENA speaker code (e.g. MAN, FAN, CHF).
9  ## Constructor
10  # @param self
11  # @param speaker_id (string) this is the 'id' name given to the speaker in the TRS file (eg. 'spk1', 'spk2', etc.)
12  # @param speaker_codeinfo (CodeInfo) A CodeInfo object (code-encapsulating object with info from the DB speaker_codes table) corresponding to this Speaker's LENA speaker code
13  def __init__(self, speaker_id, speaker_codeinfo):
14  self.speaker_id = speaker_id
15  self.speaker_codeinfo = speaker_codeinfo
16 
17  ## Checks if this speaker has a particular speaker type.
18  # @param self
19  # @param speaker_type (int) the type to check for - this should be one of the options from the enum DBConstants.SPEAKER_TYPES
20  # @returns (boolean) True if this speaker is of type 'speaker_type', False otherwise
21  def is_type(self, speaker_type):
22  return self.speaker_codeinfo and self.speaker_codeinfo.is_speaker_type(speaker_type)
23 
24  ## Checks if this speaker has particular distance (near/far)
25  # @param self
26  # @param distance (int) the distance to check for - this should be one of the options from the enum DBCONSTANTS.SPEAKER_DISTANCES
27  # @returns (boolean) True if this speaker has the specified distance, False otherwise
28  def is_distance(self, distance):
29  return self.speaker_codeinfo and self.speaker_codeinfo.is_distance(distance)
30 
31  ## Checks if this speaker has a particular property (properties include being media, being overlapping, or being non-verbal noise)
32  # @param self
33  # @param prop (int) the property to check for. This should be one of the options from the enum DBConstants.SPEAKER_PROPS. See BLLDatabase._get_speaker_props_enum() for possible options.
34  def has_property(self, prop):
35  return self.speaker_codeinfo and self.speaker_codeinfo.has_property(prop)
36 
37  ## Accessor method for codeinfo attribute.
38  # @param self
39  # @returns (CodeInfo) A CodeInfo object (parsers.codeinfo.py)
40  def get_codeinfo(self):
41  return self.speaker_codeinfo