here is the code-
import pyaudio
import wave
import os
def bass_boost(input_file, output_file, gain):
“”"
Dynamically boosts the bass in an audio file.
Args:
input_file (str): The path to the input audio file.
output_file (str): The path to the output audio file.
gain (int): The amount of bass boost to apply, in decibels.
"""
try:
wf = wave.open(input_file, "rb")
except FileNotFoundError as e:
print("The input file could not be found: {}".format(e))
return
input_format = wf.getparams()
input_channels = input_format[1]
input_sample_rate = input_format[2]
input_frames = wf.getnframes()
output_format = input_format
output_frames = input_frames
p = pyaudio.PyAudio()
stream = p.open(
format=output_format,
channels=input_channels,
rate=input_sample_rate,
output=True,
)
input_data = wf.readframes(input_frames)
output_data = [
int(sample * gain) for sample in input_data
] # Convert the samples to integers before writing them to the output file.
stream.write(output_data)
stream.close()
p.terminate()
wf.close()
if name == “main”:
input_file = “C:/Users/Sartaj/Downloads/experiment/freeflow.wav”
output_file = “C:/Users/Sartaj/Downloads/experiment/my_bass_boosted_audio.wav”
gain = 3
bass_boost(input_file, output_file, 3)
print("Bass boosted audio saved to {}.".format(output_file))