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

Split audio into words #10

Open
Tracked by #2
JulianKropp opened this issue Jul 9, 2024 · 0 comments
Open
Tracked by #2

Split audio into words #10

JulianKropp opened this issue Jul 9, 2024 · 0 comments
Assignees

Comments

@JulianKropp
Copy link
Collaborator

JulianKropp commented Jul 9, 2024

from pydub import AudioSegment
from pydub.silence import split_on_silence

# Load the audio file
sound_file = AudioSegment.from_wav("audio.wav")

# Split the audio file based on silence
audio_chunks = split_on_silence(sound_file, 
    # Must be silent for at least half a second
    min_silence_len=500,
    
    # Consider it silent if quieter than -16 dBFS
    silence_thresh=-16
)

# Export the split audio chunks
for i, chunk in enumerate(audio_chunks):
    out_file = "./splitAudio/chunk{0}.wav".format(i)
    print("exporting", out_file)
    chunk.export(out_file, format="wav")
@JulianKropp JulianKropp mentioned this issue Jul 9, 2024
10 tasks
@JulianKropp JulianKropp self-assigned this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant