Censorship Audio is a Python library that allows you to censor specific words in an audio file based on a given list of words. The library outputs a censored version of the input audio, replacing the specified words with a beep sound.
- Audio Censorship: Automatically censors a list of provided words in an audio file.
- Text-to-Speech Integration: Supports transcribing audio to text using Faster-Whisper.
- Customizable Word List: You can easily add or modify the words you want to censor.
pip install censorship-pyMake sure you have installed ffmpeg for audio processing.
Use this command if you have Linux or a subsystem (recommended)
sudo apt update && sudo apt install ffmpegOr install it on Windows using Chocolatey
choco install ffmpegHere is an example of how to use the Censorship Audio library:
from censorship import Censorship_Audio
if __name__ == "__main__":
censorship = Censorship_Audio() # Create an instance of the Censorship class
censorship.censure_audio('audio_to_censure.mp3', 'censored_audio.mp3', ['word1', 'word2'])
# Optional: Transcribe the censored audio to text
audio_to_text = censorship.return_audio_text('censored_audio.mp3')
print(audio_to_text)By default, Censorship Audio uses the large-v3 Whisper model with cpu as the device and int8 for the compute type. However, you can change these parameters based on your system's capabilities or model preferences.
You can check the differents types of models and parameter in the faster-whisper documentation.
# Create an instance with custom Whisper model parameters
# Run on GPU with FP16
censorship = Censorship_Audio(model_size='large-v2', device='"cuda"', compute_type='"float16"')If you find a bug or have an idea for improvement, feel free to open an issue or submit a pull request. Contributions are always welcome!
