Skip to content

Commit

Permalink
detect silences cache now save only silences
Browse files Browse the repository at this point in the history
  • Loading branch information
dunossauro committed Jan 23, 2025
1 parent 4a7ebaa commit becb283
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions videomaker_helper/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ def detect_silences(
*,
force: bool = False,
) -> list[float]:
times = db.search(
(where('file_name') == audio_file)
& (where('type') == 'silence')
& (where('distance') == distance),
)
times = None

if not force:
times = db.search(
(where('file_name') == audio_file)
& (where('type') == 'silence')
)

if not times or force:
logger.info(f'Reading file: {audio_file}')
Expand All @@ -154,8 +156,7 @@ def detect_silences(
{
'type': 'silence',
'file_name': str(audio_file),
'times': times,
'distance': distance,
'silences': silences,
},
)

Expand All @@ -164,4 +165,4 @@ def detect_silences(

else:
logger.info('Using db cache!')
return times[0]['times']
return _audio_chain(times[0]['silences'], distance)

0 comments on commit becb283

Please sign in to comment.