Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
parsers.wav_parser.WavParser Class Reference

This class manipulates and plays WAV audio files. More...

Inheritance diagram for parsers.wav_parser.WavParser:

Public Member Functions

def __init__
 Constructor. More...
 
def get_sound_len
 Returns a sound's length, in seconds. More...
 
def play_seg
 Plays a segment's corresponding audio clip. More...
 
def play_utter
 Plays an utterance's corresponding audio clip. More...
 
def extract_clip
 
def play_clip
 Extracts a specified chunk of audio from the wav file and plays it through the default audio device. More...
 
def close
 Closes any files or other resources used by this parser. More...
 

Public Attributes

 logger
 
 total_sec
 
 wav_in
 

Detailed Description

This class manipulates and plays WAV audio files.

This class requires the PyAudio library.

Definition at line 10 of file wav_parser.py.

Constructor & Destructor Documentation

def parsers.wav_parser.WavParser.__init__ (   self,
  filename 
)

Constructor.

Parameters
self
filename(string) full path to a WAV file

Definition at line 14 of file wav_parser.py.

Member Function Documentation

def parsers.wav_parser.WavParser.close (   self)

Closes any files or other resources used by this parser.

This should always be called after you're done with the parser!

Parameters
self

Definition at line 118 of file wav_parser.py.

def parsers.wav_parser.WavParser.extract_clip (   self,
  start_time,
  end_time,
  filename 
)

Definition at line 66 of file wav_parser.py.

def parsers.wav_parser.WavParser.get_sound_len (   self)

Returns a sound's length, in seconds.

Parameters
self
Returns
(float) The length of the sound in seconds, or zero if there was an error opening the WAV file.

Definition at line 28 of file wav_parser.py.

def parsers.wav_parser.WavParser.play_clip (   self,
  start_time,
  end_time 
)

Extracts a specified chunk of audio from the wav file and plays it through the default audio device.

Parameters
self
start_time(float) absolute start time of the clip to play, in seconds
end_time(float) absolute end time of the clip to play, in seconds

Definition at line 89 of file wav_parser.py.

def parsers.wav_parser.WavParser.play_seg (   self,
  seg,
  context_len = 0 
)

Plays a segment's corresponding audio clip.

Audio is played from (seg.start - context_len) to (seg.end + context_len).

Parameters
self
seg(Segment) The Segment object for which to play a clip
context_len(int=0) the padding length, in seconds, to be applied to both sides.

Definition at line 39 of file wav_parser.py.

def parsers.wav_parser.WavParser.play_utter (   self,
  utter,
  context_len = 0,
  play_linked = False 
)

Plays an utterance's corresponding audio clip.

Audio is played from (utter.start - context_len) to (utter.end + context_len).

Parameters
self
utter(Utterance) The Utterance object for which to play a clip
context_len(int=0) the padding length, in seconds, to be applied to both sides
play_linked(boolean=False) If true, the entire Utterance chain will be played. Otherwise only a single utternace will be played.

Definition at line 51 of file wav_parser.py.

Member Data Documentation

parsers.wav_parser.WavParser.logger

Definition at line 15 of file wav_parser.py.

parsers.wav_parser.WavParser.total_sec

Definition at line 16 of file wav_parser.py.

parsers.wav_parser.WavParser.wav_in

Definition at line 20 of file wav_parser.py.


The documentation for this class was generated from the following file: