Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes in trim_silence function regarding the agressive trimming issue #46

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions backend/app/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def _detect_leading_silence(sound: AudioSegment) -> int:
def trim_silence(path: str) -> AudioSegment:
sound = AudioSegment.from_wav(path + ".wav")
start_trim = Audio._detect_leading_silence(sound)
end_trim = Audio._detect_leading_silence(sound.reverse())
# end_trim = Audio._detect_leading_silence(sound.reverse())
duration = len(sound)
trimmed_sound = sound[start_trim:duration - end_trim]
trimmed_sound = sound[int(start_trim/2):duration]
return trimmed_sound

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion backend/app/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def save_audio(path: str, audio: bytes):
with open(webm_file_name, 'wb+') as f:
f.write(audio)
subprocess.call(
'ffmpeg -i {} -ab 160k -ac 2 -ar 44100 -vn {}.wav -y'.format(
'ffmpeg -i {} -ab 160k -ac 1 -ar 44100 -vn {}.wav -y'.format(
webm_file_name, path
),
shell=True
Expand Down
Loading