Fix up silence detection from last commit
This commit is contained in:
parent
11e3536801
commit
00cae6dc52
@ -168,7 +168,8 @@ def leading_silence(audio_segment, silence_threshold=Config.DBFS_SILENCE,
|
|||||||
return min(trim_ms, len(audio_segment))
|
return min(trim_ms, len(audio_segment))
|
||||||
|
|
||||||
|
|
||||||
def fade_point(audio_segment, chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
|
def fade_point(audio_segment, fade_threshold=0,
|
||||||
|
chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
|
||||||
"""
|
"""
|
||||||
Returns the millisecond/index of the point where the volume drops below
|
Returns the millisecond/index of the point where the volume drops below
|
||||||
the maximum and doesn't get louder again.
|
the maximum and doesn't get louder again.
|
||||||
@ -182,7 +183,8 @@ def fade_point(audio_segment, chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
|
|||||||
segment_length = audio_segment.duration_seconds * 1000 # ms
|
segment_length = audio_segment.duration_seconds * 1000 # ms
|
||||||
trim_ms = segment_length - chunk_size
|
trim_ms = segment_length - chunk_size
|
||||||
max_vol = audio_segment.dBFS
|
max_vol = audio_segment.dBFS
|
||||||
fade_threshold = max_vol
|
if fade_threshold == 0:
|
||||||
|
fade_threshold = max_vol
|
||||||
|
|
||||||
while (
|
while (
|
||||||
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < fade_threshold
|
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < fade_threshold
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user