{"id":21101987,"url":"https://github.com/etienneab3d/whisperhallu","last_synced_at":"2025-05-16T18:07:59.123Z","repository":{"id":102531938,"uuid":"601682416","full_name":"EtienneAb3d/WhisperHallu","owner":"EtienneAb3d","description":"Experimental code: sound file preprocessing to optimize Whisper transcriptions without hallucinated texts","archived":false,"fork":false,"pushed_at":"2024-11-12T07:12:18.000Z","size":12711,"stargazers_count":317,"open_issues_count":11,"forks_count":23,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-03T19:13:43.755Z","etag":null,"topics":["asr","audio-processing","noise-removal","sound-processing","text-to-speech","vad","vocals","whisper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EtienneAb3d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-02-14T15:39:30.000Z","updated_at":"2025-04-02T08:19:37.000Z","dependencies_parsed_at":"2024-11-20T00:03:50.914Z","dependency_job_id":null,"html_url":"https://github.com/EtienneAb3d/WhisperHallu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EtienneAb3d%2FWhisperHallu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EtienneAb3d%2FWhisperHallu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EtienneAb3d%2FWhisperHallu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EtienneAb3d%2FWhisperHallu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EtienneAb3d","download_url":"https://codeload.github.com/EtienneAb3d/WhisperHallu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248601079,"owners_count":21131607,"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":["asr","audio-processing","noise-removal","sound-processing","text-to-speech","vad","vocals","whisper"],"created_at":"2024-11-19T23:51:09.452Z","updated_at":"2025-04-12T16:48:45.568Z","avatar_url":"https://github.com/EtienneAb3d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WhisperHallu\nExperimental code: sound file preprocessing to optimize Whisper transcriptions without hallucinated texts\n\nSee this discussion: https://github.com/openai/whisper/discussions/679\n\n# Main algo\n- remove noise by voice extraction using  [Facebook Demucs](https://github.com/facebookresearch/demucs) or [Deezer Spleeter](https://github.com/deezer/spleeter).\n- remove silences, and normalize loudness with ffmpeg.\n- remove noise parts using [Silero VAD](https://github.com/snakers4/silero-vad).\n- add voice markers.\n- apply speech compressor (requires `ffmpeg` 4.4, while Google Colab is 4.2, it has to be upgraded, see below).\n- try to transcribe. If markers are present in output, transcription is OK.\n- if not, try to invert markers. If markers are present in output, transcription is OK.\n- if not, try without markers.\n\n# Processing options and parameters\n- use Whisper V1, V2 or V3 (V2 by default, because V3 seems bad with music).\n- beam_size (2 by default), patience, temperature.\n- process only a subpart of the input file (needs a post-processing of timestamp values).\n- various time stretching methods tested (see in-code comments. Needs a post-processing of timestamp values. It was an interesting suggested idea, but no real gain obtained on my side).\n- vocals remix (with or without speech normalization).\n- multiple final transcriptions (get multiple results, knowing Whisper is not stable from one run to an other, without doing pre-processing several times) \n\n# Complement\n\nMay be used to produce \"accurate transcriptions\" for WhisperTimeSync:\u003cbr/\u003e\nhttps://github.com/EtienneAb3d/WhisperTimeSync\n\nMay be tested using NeuroSpell Dictaphone:\u003cbr/\u003e\nhttps://neurospell.com/\n\nWhisperHallu and WhisperTimeSync are used to extract vocals and lyrics in karaok-AI:\u003cbr/\u003e\nhttps://github.com/EtienneAb3d/karaok-AI\n\nChatMate is a complete versatile ChatGPT automation tool, including explanations to produce a SRT file translator to Chinese (as an example):\u003cbr/\u003e\nhttps://github.com/EtienneAb3d/ChatMate\n\n# Google Colab\n\nStandard Whisper:\u003cbr/\u003e\nhttps://colab.research.google.com/drive/1-GpXaNaGFXKX9VXl60JGVVrGO41t09KA?usp=sharing\n\nFaster Whisper:\u003cbr/\u003e\nhttps://colab.research.google.com/drive/1RkvOtUTbUD5NVsRI4aKEqJO8BRo8BFIY?usp=sharing\n\n# Install\n\n**Check ffmpeg version \u003e=4.4**\n```sh\nffmpeg -version\n\nOutput should be:\n=================\nffmpeg version 4.4.3-0ubuntu1~20.04.sav2 Copyright (c) 2000-2022 the FFmpeg developers\n[...]\n\nInstall latest:\n===============\nsudo add-apt-repository -y ppa:savoury1/ffmpeg4\nsudo apt-get -qq install -y ffmpeg\n\n```\n\n**Demucs (if used)**\n\n```sh\npip install -U demucs\n```\n\n**Spleeter (if used)**\n\n```sh\npip install spleeter\n```\n\n**Standard Whisper (if used)**\n\n```sh\nsudo apt update \u0026\u0026 sudo apt install ffmpeg\n\nsudo apt install python3\nsudo apt install python3-pip\nsudo apt install virtualenv\n\nvirtualenv -p python3 ../venvWhisper\n. ../venvWhisper/bin/activate\n\npip install -U openai-whisper\n\npip3 install torchaudio\n```\n\n**Faster Whisper (if used in place of Whisper)**\n\n```sh\nsudo apt update \u0026\u0026 sudo apt install ffmpeg\n\nsudo apt install python3\nsudo apt install python3-pip\nsudo apt install virtualenv\n\nvirtualenv -p python3 ../venvFasterWhisper\n. ../venvFasterWhisper/bin/activate\n\ngit clone https://github.com/guillaumekln/faster-whisper.git\ncd faster-whisper/\n\npip install -e .[conversion]\npip install -e .\n\ncd ..\n\nct2-transformers-converter --model openai/whisper-medium --output_dir whisper-medium-ct2 --quantization float16\nct2-transformers-converter --model openai/whisper-large --output_dir whisper-large-ct2 --quantization float16\n\npip3 install torchaudio\n```\n\n**SM4T (if used in place of Whisper)**\n\n```sh\nsudo apt update \u0026\u0026 sudo apt install ffmpeg\n\nsudo apt install python3\nsudo apt install python3-pip\nsudo apt install virtualenv\n\nvirtualenv -p python3 ../venvSM4T\n. ../venvSM4T/bin/activate\n\ngit clone https://github.com/facebookresearch/seamless_communication.git\ncd seamless_communication/\n\npip install --upgrade pip\npip install .\n\nm4t_predict \"On ne fait pas d'omelette sans casser des oeufs.\" t2tt eng --src_lang fra\n\npip3 install torchaudio\n```\n\n# Code\n\n```python\nfrom transcribeHallu import loadModel\nfrom transcribeHallu import transcribePrompt\n\n##### The audio language may be different from the one for the output transcription.\npath=\"/path/to/your/en/sound/file\"\nlngInput=\"en\"\n\n##### Activate this for music file to get a minimal processing\nisMusic=False\n\n##### Need to be adapted for each language.\n##### For prompt examples, see transcribeHallu.py getPrompt(lng:str)\nlng=\"en\"\nprompt= \"Whisper, Ok. \"\\\n\t+\"A pertinent sentence for your purpose in your language. \"\\\n\t+\"Ok, Whisper. Whisper, Ok. \"\\\n\t+\"Ok, Whisper. Whisper, Ok. \"\\\n\t+\"Please find here, an unlikely ordinary sentence. \"\\\n\t+\"This is to avoid a repetition to be deleted. \"\\\n\t+\"Ok, Whisper. \"\n\n##### Model size to use\nmodelSize=\"medium\"\nloadModel(\"0\",modelSize=modelSize)\n\nresult = transcribePrompt(path=path, lng=lng, prompt=prompt, lngInput=lngInput,isMusic=isMusic)\n```\n\n\u003chr\u003e\nThis tool is a demonstration of our know-how.\u003cbr/\u003e\nIf you are interested in a commercial/industrial AI linguistic project, contact us:\u003cbr/\u003e\nhttps://cubaix.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetienneab3d%2Fwhisperhallu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetienneab3d%2Fwhisperhallu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetienneab3d%2Fwhisperhallu/lists"}