mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
strip noise profile code
This commit is contained in:
parent
c682080890
commit
82d006d145
1 changed files with 3 additions and 38 deletions
|
@ -21,8 +21,6 @@ def hasSound(text):
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# the amount of noise to cancel
|
|
||||||
NOISE_AMOUNT = "0.1"
|
|
||||||
# the amount of amplification
|
# the amount of amplification
|
||||||
NORM_AMOUNT = "-3"
|
NORM_AMOUNT = "-3"
|
||||||
# the amount of bass
|
# the amount of bass
|
||||||
|
@ -30,19 +28,15 @@ BASS_AMOUNT = "+0"
|
||||||
# the amount to fade at end
|
# the amount to fade at end
|
||||||
FADE_AMOUNT = "0.25"
|
FADE_AMOUNT = "0.25"
|
||||||
|
|
||||||
noiseProfile = ""
|
|
||||||
|
|
||||||
processingSrc = "rec.wav"
|
processingSrc = "rec.wav"
|
||||||
processingDst = "rec.mp3"
|
processingDst = "rec.mp3"
|
||||||
processingChain = []
|
processingChain = []
|
||||||
recFiles = ["rec2.wav", "rec3.wav"]
|
recFiles = ["rec2.wav"]
|
||||||
|
|
||||||
cmd = ["sox", processingSrc, "rec2.wav"]
|
|
||||||
processingChain = [
|
processingChain = [
|
||||||
None, # placeholder
|
["sox", "rec.wav", "rec2.wav", "norm", NORM_AMOUNT,
|
||||||
["sox", "rec2.wav", "rec3.wav", "norm", NORM_AMOUNT,
|
|
||||||
"bass", BASS_AMOUNT, "fade", FADE_AMOUNT],
|
"bass", BASS_AMOUNT, "fade", FADE_AMOUNT],
|
||||||
["lame", "rec3.wav", processingDst, "--noreplaygain", "--quiet"],
|
["lame", "rec2.wav", processingDst, "--noreplaygain", "--quiet"],
|
||||||
]
|
]
|
||||||
|
|
||||||
tmpdir = None
|
tmpdir = None
|
||||||
|
@ -76,35 +70,6 @@ def retryWait(proc):
|
||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Noise profiles
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
def checkForNoiseProfile():
|
|
||||||
global processingChain
|
|
||||||
if sys.platform.startswith("darwin"):
|
|
||||||
# not currently supported
|
|
||||||
processingChain = [
|
|
||||||
["lame", "rec.wav", "rec.mp3", "--noreplaygain", "--quiet"]]
|
|
||||||
else:
|
|
||||||
cmd = ["sox", processingSrc, "rec2.wav"]
|
|
||||||
if os.path.exists(noiseProfile):
|
|
||||||
cmd = cmd + ["noisered", noiseProfile, NOISE_AMOUNT]
|
|
||||||
processingChain[0] = cmd
|
|
||||||
|
|
||||||
def generateNoiseProfile():
|
|
||||||
try:
|
|
||||||
os.unlink(noiseProfile)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
retryWait(subprocess.Popen(
|
|
||||||
["sox", processingSrc, recFiles[0], "trim", "1.5", "1.5"],
|
|
||||||
startupinfo=si))
|
|
||||||
retryWait(subprocess.Popen(["sox", recFiles[0], recFiles[1],
|
|
||||||
"noiseprof", noiseProfile],
|
|
||||||
startupinfo=si))
|
|
||||||
processingChain[0] = ["sox", processingSrc, "rec2.wav",
|
|
||||||
"noisered", noiseProfile, NOISE_AMOUNT]
|
|
||||||
|
|
||||||
# Mplayer settings
|
# Mplayer settings
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue