def generate_frames(self, frame_duration_ms, zero_pad=True):
Frame = collections.namedtuple("<STR_LIT>", "<STR_LIT>")<EOL>bytes_per_frame = int(self.frame_rate * (frame_duration_ms / <NUM_LIT:1000>) * self.sample_width)<EOL>offset = <NUM_LIT:0>  <EOL>timestamp = <NUM_LIT:0.0>  <EOL>frame_duration_s = (bytes_per_frame / self.frame_rate) / self.sample_width<EOL>while offset + bytes_per_frame < len(self.raw_data):<EOL><INDENT>yield Frame(self.raw_data[offset:offset + bytes_per_frame], timestamp, frame_duration_s)<EOL>timestamp += frame_duration_s<EOL>offset += bytes_per_frame<EOL><DEDENT>if zero_pad:<EOL><INDENT>rest = self.raw_data[offset:]<EOL>zeros = bytes(bytes_per_frame - len(rest))<EOL>yield Frame(rest + zeros, timestamp, frame_duration_s)<EOL><DEDENT>
Yields self's data in chunks of frame_duration_ms.

This function adapted from pywebrtc's example [https://github.com/wiseman/py-webrtcvad/blob/master/example.py].

:param frame_duration_ms: The length of each frame in ms.
:param zero_pad: Whether or not to zero pad the end of the AudioSegment object to get all
                 the audio data out as frames. If not, there may be a part at the end
                 of the Segment that is cut off (the part will be <= `frame_duration_ms` in length).
:returns: A Frame object with properties 'bytes (the data)', 'timestamp (start time)', and 'duration'.