Skip to content

Commit

Permalink
Merge pull request #47 from MycroftAI/bugfix/aggressive-trimming
Browse files Browse the repository at this point in the history
Provide 0.3s buffer for silence trimming
  • Loading branch information
krisgesling committed Jun 15, 2021
2 parents e3e3c8e + ffd7e96 commit e57b1ff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/app/audio.py
Expand Up @@ -13,7 +13,10 @@ def _detect_leading_silence(sound: AudioSegment) -> int:
while sound[trim_ms:trim_ms + Audio.chunk_size].dBFS \
< Audio.silence_threshold and trim_ms < len(sound):
trim_ms += Audio.chunk_size

trim_buffer = 300 # buffer to prevent first sound getting cut
trim_ms -= trim_buffer
if trim_ms < 0:
trim_ms = 0
return trim_ms

@staticmethod
Expand Down

0 comments on commit e57b1ff

Please sign in to comment.