-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSample.py
More file actions
23 lines (19 loc) · 679 Bytes
/
Copy pathSample.py
File metadata and controls
23 lines (19 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Metadata
class Sample(object):
'''
Represents a particular audio track - maintains metadata about the audio file for faster audio handling during training
'''
def __init__(self, path, sample_rate, channels, duration):
self.path = path
self.sample_rate = sample_rate
self.channels = channels
self.duration = duration
@classmethod
def from_path(cls, path):
'''
Create new sample object from audio file path by retrieving metadata.
:param path:
:return:
'''
sr, channels, duration = Metadata.get_audio_metadata(path)
return cls(path, sr, channels, duration)