Change algorithm to detect fade point
This commit is contained in:
parent
b4da349a8c
commit
427afee8da
@ -168,11 +168,10 @@ def leading_silence(audio_segment, silence_threshold=Config.DBFS_SILENCE,
|
||||
return min(trim_ms, len(audio_segment))
|
||||
|
||||
|
||||
def fade_point(audio_segment, fade_threshold=Config.DBFS_FADE,
|
||||
chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
|
||||
def fade_point(audio_segment, chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
|
||||
"""
|
||||
Returns the millisecond/index of the point where the fade is down to
|
||||
fade_threshold and doesn't get louder again.
|
||||
Returns the millisecond/index of the point where the volume drops below
|
||||
the maximum and doesn't get louder again.
|
||||
audio_segment - the sdlg_search_database_uiegment to find silence in
|
||||
fade_threshold - the upper bound for how quiet is silent in dFBS
|
||||
chunk_size - chunk size for interating over the segment in ms
|
||||
@ -182,6 +181,9 @@ def fade_point(audio_segment, fade_threshold=Config.DBFS_FADE,
|
||||
|
||||
segment_length = audio_segment.duration_seconds * 1000 # ms
|
||||
trim_ms = segment_length - chunk_size
|
||||
max_vol = audio_segment.dBFS
|
||||
fade_threshold = max_vol
|
||||
|
||||
while (
|
||||
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < fade_threshold
|
||||
and trim_ms > 0): # noqa W503
|
||||
|
||||
Loading…
Reference in New Issue
Block a user