Skip to content

Commit

Permalink
aaaaaaah
Browse files Browse the repository at this point in the history
  • Loading branch information
Doggies-Galore committed May 1, 2024
1 parent 2e63b28 commit 8048ff8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Binary file not shown.
33 changes: 33 additions & 0 deletions combine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pydub import AudioSegment
import os

def combine_audio_files(input_dir, output_file, verbose=True):
# Check if the output file already exists, if so, delete it
if os.path.exists(output_file):
os.remove(output_file)

# Create an empty audio segment to store the combined audio
combined_audio = AudioSegment.silent(duration=0)

# Loop through all files in the input directory
for file_name in os.listdir(input_dir):
if file_name.endswith('.mp3') or file_name.endswith('.wav'):
# Load the audio file
audio = AudioSegment.from_file(os.path.join(input_dir, file_name))

# Append the audio to the combined audio segment
combined_audio += audio

if verbose:
print(f"Added '{file_name}' to the combined audio.")

# Export the combined audio to the output file
combined_audio.export(output_file, format="mp3")

if verbose:
print("Audio files combined successfully!")

# Example usage:
input_directory = "audio"
output_file = "all.mp3"
combine_audio_files(input_directory, output_file)

0 comments on commit 8048ff8

Please sign in to comment.