-
-
Save esurdam/9708fbd2c104e45e44a065b68700f1ce to your computer and use it in GitHub Desktop.
py.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output = popen("/usr/local/bin/ffprobe -v error -show_format -show_streams %s" % self._audio).read() | |
for spec in {'sample_rate', 'channels'}: | |
eval(u'{0:s} = popen("echo "{0:s}" | grep {0:s}).read().replace("{0:s}=", "").rstrip("\n")'.format(spec)) | |
# sample_rate = popen("echo \"%s\" | grep sample_rate" % output).read().replace("sample_rate=", "").rstrip('\n') | |
# channels = popen("echo \"%s\" | grep channels" % output).read().replace("channels=", "").rstrip('\n') | |
if int(sample_rate) > 16000 or int(channels) > 1: | |
filename, extension = self._audio.split('.') | |
output_file = ".%s_mono.%s" % (filename, extension) | |
system('/usr/local/bin/ffmpeg -y -i %s -out_sample_rate 16000 -ac 1 %s &> /dev/null' % (self._audio, output_file)) | |
if isfile(output_file): | |
self._audio = output_file | |
return isfile(output_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment