blob: f17748abf93d5eec6ca9a45e958224c65aff09f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
class BaseHandler:
def __init__(self, logger = None):
self.logger = logger
self.buf = []
def log(self, fmt, *args):
if self.logger is not None:
self.logger(fmt, *args)
def add(self, *args):
self.buf.extend(args)
def build(self, join=True):
data = " ".join(self.buf) if join else self.buf
self.buf = []
return data
def add_sox_args(self, opt, info):
if opt.sample_rate and opt.sample_rate != info.sample_rate:
self.add("-r %d" % opt.sample_rate)
if opt.bits_per_sample and opt.bits_per_sample != info.bits_per_sample:
self.add("-b %d" % opt.bits_per_sample)
if opt.channels and opt.channels != info.channels:
self.add("-c %d" % opt.channels)
def is_tag_supported(self):
return hasattr(self, "tag")
|