{"id":26228949,"url":"https://github.com/thunderpoot/audio-censor","last_synced_at":"2025-12-11T18:55:35.404Z","repository":{"id":248740695,"uuid":"829544270","full_name":"thunderpoot/audio-censor","owner":"thunderpoot","description":"Rudimentary program for speech transcription, manipulation, and redaction.","archived":false,"fork":false,"pushed_at":"2024-07-17T14:41:17.000Z","size":788,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-17T22:07:24.770Z","etag":null,"topics":["audio","censor","censorship","pydub","redaction","speech","transcription","vosk","vosk-models","wavesurfer"],"latest_commit_sha":null,"homepage":"https://thunderpoot.github.io/audio-censor/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thunderpoot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-16T16:38:21.000Z","updated_at":"2024-07-17T14:41:26.000Z","dependencies_parsed_at":"2024-07-21T01:45:19.929Z","dependency_job_id":null,"html_url":"https://github.com/thunderpoot/audio-censor","commit_stats":null,"previous_names":["thunderpoot/audio-censor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderpoot%2Faudio-censor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderpoot%2Faudio-censor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderpoot%2Faudio-censor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderpoot%2Faudio-censor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thunderpoot","download_url":"https://codeload.github.com/thunderpoot/audio-censor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243300167,"owners_count":20269251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","censor","censorship","pydub","redaction","speech","transcription","vosk","vosk-models","wavesurfer"],"created_at":"2025-03-12T21:34:46.970Z","updated_at":"2025-12-11T18:55:35.393Z","avatar_url":"https://github.com/thunderpoot.png","language":"Python","readme":"# Speech Censoring \u0026 Manipulation\n\nHere's a [very rudimentary](https://www.google.com/search?q=define:jank) program for censoring and rearranging speech sounds in an audio file.  It supports multiple input formats and has several options.\n\nThis program processes an audio file, identifies specified words, and censors them by replacing them with beeps. Optionally, the [words may be rearranged](https://youtu.be/LzoNAsXELBk?t=1369) by supplying a text file with the desired speech output. The transcript can be returned without censoring if desired.\n\n## Requirements\n\n- Python 3\n- [pydub](https://pypi.org/project/pydub/)\n- [vosk](https://alphacephei.com/vosk/)\n    - The smallest (40M) en-US model can be used (YMMV). The larger (1.8G) model might be more accurate.  Download the desired model from [here](https://alphacephei.com/vosk/models), and put it in the project directory.\n- argparse\n- wave\n- datetime\n- json\n\n## Installation\n\nInstall the required Python libraries using `pip`:\n\n```sh\npip install pydub vosk argparse\n```\n\n## Usage\n\nTo run the script:\n\n```sh\n./audio-censor.py --audio_file \u003cpath_to_audio_file\u003e --model_path \u003cpath_to_vosk_model\u003e [OPTIONS]\n```\n\nThe larger vosk models take longer to use, obviously\n\n## Examples\n\nHere are some examples, which use this example audio from the Speech Synthesis group at [Kungliga Tekniska Högskolan](https://www.speech.kth.se/) (KTH):\n\nhttps://github.com/user-attachments/assets/b1306668-777e-4ec1-9afa-45a2cb287378\n\n```text\nit had established periodic regular review of the status of four hundred individuals\n```\n\n### Example 1 command\n\nWe will censor the words \"established\", \"review\", \"status\", and \"individuals\".\n\n```sh\n./audio-censor.py --audio_file examples/mat.mp3 --bad_words_file examples/mat_redact.csv --model_path vosk-model-small-en-us-0.15/ --output_format aiff\n```\n\n### Example 1 output\n\n```text\nAudio file: examples/mat.mp3\nModel path: vosk-model-small-en-us-0.15/\nLoaded audio file examples/mat.mp3, duration: 5515 ms, frame_count=121600.0\nAudio segment before export: duration=5515 ms, frame_count=88236.0\nExported audio to temp.wav\ntemp.wav properties: channels=1, sample_width=2, frame_rate=16000, frames=88236\nRaw transcript:\nit had established periodic regular review of the status of four hundred individuals\nLoaded bad words: ['established', 'review', 'status', 'individuals']\nCensored Transcript:\nit had [redacted] periodic regular [redacted] of the [redacted] of four hundred [redacted]\n```\n\nhttps://github.com/user-attachments/assets/4bd87624-c994-4e60-8f66-bbec7a3e70d1\n\n![Figure_1](examples/Figure_1.png)\n![Figure_2](examples/Figure_2.png)\n\n### Example 2 command\n\nWe will rearrange the words to say something else\"\n\n```text\nit had established review of this periodic regular status of four hundred established individuals review status periodic it had\n```\n\n```sh\n./audio-censor.py --audio_file examples/mat.mp3 --model_path vosk-model-small-en-us-0.15/ --new_transcript examples/mat_new.txt --nocensor\n```\n\n### Example 2 output\n\n```text\nAudio file: examples/mat.mp3\nModel path: vosk-model-small-en-us-0.15/\nLoaded audio file examples/mat.mp3, duration: 5515 ms, frame_count=121600.0\nAudio segment before export: duration=5515 ms, frame_count=88236.0\nExported audio to temp.wav\ntemp.wav properties: channels=1, sample_width=2, frame_rate=16000, frames=88236\nRaw transcript:\nit had established periodic regular review of the status of four hundred individuals\nLoaded new transcript: ['it', 'had', 'established', 'review', 'of', 'the', 'periodic', 'regular', 'status', 'of', 'four', 'hundred', 'established', 'individuals', 'review', 'status', 'periodic', 'it', 'had']\nAudio segment before export: duration=8100 ms, frame_count=129600.0\nExported audio to temp.wav\ntemp.wav properties: channels=1, sample_width=2, frame_rate=16000, frames=129600\nNew Transcript: it had established review of this periodic regular status of four hundred established individuals review status periodic it had\nTranscript Without Censoring:\nit had established review of this periodic regular status of four hundred established individuals review status periodic it had\nSaved rearranged audio to mat_rearranged_20240716_215400.mp3\n```\n\nhttps://github.com/user-attachments/assets/5e2de996-fb2d-4fa6-980f-94e0c4a48ff2\n\nThe supplied \"new transcript\" is gibberish but demonstrates the rearrangement functionality.\n\n### Example 3 command\n\nWe will attempt to make Orson Welles' job a bit easier.\n\n```sh\n./audio-censor.py --audio_file examples/orson.mp3 --model_path vosk-model-en-us-0.22/ --bad_words examples/mat_redact.csv --new_transcript examples/orson_new.txt\n```\n\n#### Input file\n\nhttps://github.com/user-attachments/assets/b4e5671c-d228-42ca-9474-927b1781b5c5\n\n```text\nbecause Findus freeze the cod at sea and then add a crumb crisp ooh crumb crisp coating ah that's tough crumb crisp coating\n```\n\n### Example 3 output\n\n```text\n$ ./audio-censor.py --audio_file examples/orson.mp3 --model_path vosk-model-en-us-0.22/ --bad_words examples/mat_redact.csv --new_transcript examples/orson_new.txt\nAudio file: examples/orson.mp3\nModel path: vosk-model-en-us-0.22/\nLoaded audio file examples/orson.mp3, duration: 12584 ms, frame_count=554944.0\nAudio segment before export: duration=12584 ms, frame_count=201340.0\nExported audio to temp.wav\ntemp.wav properties: channels=1, sample_width=2, frame_rate=16000, frames=201340\nRaw transcript:\nit's an endless freeze the car to see and then add crumb crust crumb crisp coating let's cut from crisp coating\nLoaded bad words: ['established', 'review', 'status', 'individuals']\nLoaded new transcript: ['because', 'Findus', 'freeze', 'the', 'cod', 'at', 'sea', 'and', 'then', 'add', 'a', 'crisp', 'coating']\nWord 'because' not found in the original transcript.\nWord 'Findus' not found in the original transcript.\nWord 'cod' not found in the original transcript.\nWord 'at' not found in the original transcript.\nWord 'sea' not found in the original transcript.\nWord 'a' not found in the original transcript.\nAudio segment before export: duration=2100 ms, frame_count=33600.0\nExported audio to temp.wav\ntemp.wav properties: channels=1, sample_width=2, frame_rate=16000, frames=33600\nNew Transcript: i use them and add coffee\nCensored Transcript:\ni use them and add coffee\nSaved cleaned audio to orson_cleaned_20240716_215919.mp3\n```\n\nAs you can see, the recognition does not really understand Orson Welles and parses his speech incorrectly.\n\nhttps://github.com/user-attachments/assets/6dd0df5b-fd39-4617-9d00-d1099577054e\n\nSo, we can use the [web app](https://thunderpoot.github.io/audio-censor/) to manually transcribe the audio file:\n\n![transcription-web-app-screenshot](examples/transcription-web-app-screenshot.png)\n\n... and then use the resulting JSON file as a manual transcription, so that we get the desired output audio:\n\n```sh\n./audio-censor.py --audio_file examples/orson.mp3 --model_path vosk-model-small-en-us-0.15 --new_transcript examples/orson_new.txt --nocensor --transcript_json_path examples/orson_transcript.json\n```\n\n```text\nAudio file: examples/orson.mp3\nModel path: vosk-model-small-en-us-0.15\nLoaded audio file examples/orson.mp3, duration: 12584 ms, frame_count=554944.0\nRaw transcript:\nbecause findus freeze the cod at sea and then add a crumb crisp ooh crumb crisp coating ah that's tough crumb crisp coating\nLoaded new transcript: ['because', 'findus', 'freeze', 'the', 'cod', 'at', 'sea', 'and', 'then', 'add', 'a', 'crisp', 'coating']\nAudio segment before export: duration=4419 ms, frame_count=70702.0\nExported audio to temp.wav\ntemp.wav properties: channels=1, sample_width=2, frame_rate=16000, frames=70702\nSaved rearranged audio to orson_rearranged_20240717_010213.mp3\n```\n\nhttps://github.com/user-attachments/assets/3a8fc632-3f09-40d8-ad77-c0ec9c0038a0\n\n\n## Workflow Diagram\n\n```mermaid\ngraph TD\nA[Start] --\u003e B[Parse Arguments]\nB --\u003e C{Transcript JSON Provided?}\nC -- Yes --\u003e D[Load JSON Transcript]\nC -- No --\u003e E{Transcribe Only?}\nE -- Yes --\u003e F[Transcribe Audio and Output Transcript]\nE -- No --\u003e G[Load and Transcribe Audio]\nD --\u003e H{Rearrange Words?}\nG --\u003e H\nH -- Yes --\u003e I[Rearrange Words in Transcript]\nH -- No --\u003e J[Skip Rearranging]\nI --\u003e K{Censoring?}\nJ --\u003e K\nK -- No --\u003e L[Output Transcript and Audio File]\nK -- Yes --\u003e M{Bad Words Provided?}\nM -- No --\u003e N[Error: No Bad Words]\nM -- Yes --\u003e O[Censor Bad Words]\nO --\u003e P[Beep Out Bad Words]\nP --\u003e Q[Output Cleaned Audio]\nL --\u003e R[End]\nQ --\u003e R\n```\n\n\n## Errata\n\nProbably many. Raise an issue in this repository if you want, but there's no guarantee it will ever be fixed.\nThe argument parsing and a bunch of other things need improvement but for a prototype [this is fine](https://knowyourmeme.com/memes/this-is-fine)\n\n## To Do\n\n- Improve stylesheet of web transcription interface\n\n## License \u0026 Whatever\n\nCopyright (c) 2024 T E Vaughan\n\n[Schrödinger License](license.md)\n\n[Hello, Smithers](https://www.youtube.com/watch?v=8YzSHIYxdRs)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthunderpoot%2Faudio-censor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthunderpoot%2Faudio-censor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthunderpoot%2Faudio-censor/lists"}