From a5264ce0f7f4da048734d9e61cd8c51104f124d6 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Mon, 21 Jul 2014 09:13:23 +0300 Subject: [PATCH] pylint wave.py --- wave.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/wave.py b/wave.py index 5b18f9e..474ef1c 100755 --- a/wave.py +++ b/wave.py @@ -7,17 +7,22 @@ import logging log = logging.getLogger(__name__) from common import Fs -Fs = int(Fs) # sampling rate +Fs = int(Fs) # sampling rate bits_per_sample = 16 bytes_per_second = bits_per_sample * Fs / 8.0 -audio_format = 'S{}_LE'.format(bits_per_sample) # PCM signed little endian +audio_format = 'S{}_LE'.format(bits_per_sample) # PCM signed little endian + def play(fname, **kwargs): - return launch('aplay', fname, '-q', '-f', audio_format, '-c', '1', '-r', Fs, **kwargs) + args = ['aplay', fname, '-q', '-f', audio_format, '-c', '1', '-r', Fs] + return launch(*args, **kwargs) + def record(fname, **kwargs): - return launch('arecord', fname, '-q', '-f', audio_format, '-c', '1', '-r', Fs, **kwargs) + args = ['arecord', fname, '-q', '-f', audio_format, '-c', '1', '-r', Fs] + return launch(*args, **kwargs) + def launch(*args, **kwargs): args = map(str, args) @@ -34,11 +39,15 @@ if __name__ == '__main__': subparsers = parser.add_subparsers() fmt = 'a raw audio file (16 bits at {:.1f} kHz)'.format(Fs / 1e3) recorder = subparsers.add_parser('record', help='record ' + fmt) - recorder.add_argument('filename', default='-', help='path to the audio file to record (otherwise, use stdout)') + recorder.add_argument( + 'filename', default='-', + help='path to the audio file to record (otherwise, use stdout)') recorder.set_defaults(func=record) player = subparsers.add_parser('play', help='play ' + fmt) - player.add_argument('filename', default='-', help='path to the audio file to play (otherwise, use stdin)') + player.add_argument( + 'filename', default='-', + help='path to the audio file to play (otherwise, use stdin)') player.set_defaults(func=play) args = parser.parse_args()