Skip to content

Instantly share code, notes, and snippets.

@rishubil
Last active March 4, 2024 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rishubil/bc5dcadea00cc313980dbae47b885c4c to your computer and use it in GitHub Desktop.
Save rishubil/bc5dcadea00cc313980dbae47b885c4c to your computer and use it in GitHub Desktop.
Video to SRT
@REM How to use
@REM 1. Download lastest release of whisper-faster.exe from https://github.com/Purfview/whisper-standalone-win/releases and extract it
@REM 2. Copy this file and save as "video-to-srt.bat" in the same folder as whisper-faster.exe
@REM 3. Drag and drop video file to "video-to-srt.bat"
@REM 4. Wait for a while until "Press any key to continue . . ." appears
@REM 5. Check the folder where the video file is located
@REM FAQ
@REM Q. How to change the language?
@REM A. Change the language in the 39th line of this file.
@REM Available languages:
@REM Afrikaans,Albanian,Amharic,Arabic,Armenian,Assamese,Azerbaijani,
@REM Bashkir,Basque,Belarusian,Bengali,Bosnian,Breton,Bulgarian,Burmese,
@REM Castilian,Catalan,Chinese,Croatian,Czech,Danish,Dutch,English,Estonian,
@REM Faroese,Finnish,Flemish,French,Galician,Georgian,German,Greek,Gujarati,
@REM Haitian,Haitian Creole,Hausa,Hawaiian,Hebrew,Hindi,Hungarian,Icelandic,Indonesian,Italian,
@REM Japanese,Javanese,Kannada,Kazakh,Khmer,Korean,Lao,Latin,Latvian,Letzeburgesch,Lingala,Lithuanian,Luxembourgish,
@REM Macedonian,Malagasy,Malay,Malayalam,Maltese,Maori,Marathi,Moldavian,Moldovan,Mongolian,Myanmar,
@REM Nepali,Norwegian,Nynorsk,Occitan,Panjabi,Pashto,Persian,Polish,Portuguese,Punjabi,Pushto,Romanian,Russian,
@REM Sanskrit,Serbian,Shona,Sindhi,Sinhala,Sinhalese,Slovak,Slovenian,Somali,Spanish,Sundanese,Swahili,Swedish,
@REM Tagalog,Tajik,Tamil,Tatar,Telugu,Thai,Tibetan,Turkish,Turkmen,Ukrainian,Urdu,Uzbek,
@REM Valencian,Vietnamese,Welsh,Yiddish,Yoruba
@REM Q. How to change the model?
@REM A. Change the model in the 39th line of this file.
@REM Available models:
@REM tiny,bases,small,medium,large-v2
chcp 65001
IF NOT EXIST "%~dp0ffmpeg-n6.0-latest-win64-gpl-shared-6.0\bin\ffmpeg.exe" (
powershell -command "Start-BitsTransfer -Source https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.0-latest-win64-gpl-shared-6.0.zip -Destination "^""%~dp0ffmpeg-n6.0-latest-win64-gpl-shared-6.0.zip"^"""
powershell -command "Expand-Archive "^""%~dp0ffmpeg-n6.0-latest-win64-gpl-shared-6.0.zip"^"" "^""%~dp0."^"""
del "%~dp0ffmpeg-n6.0-latest-win64-gpl-shared-6.0.zip"
)
cd "%~dp0"
"%~dp0ffmpeg-n6.0-latest-win64-gpl-shared-6.0\bin\ffmpeg.exe" -i "%~1" -ar 16000 -ac 1 -c:a pcm_s16le "%~1.wav"
"%~dp0whisper-faster.exe" --model medium --language Korean --output_format srt --device cpu --beep_off --vad_filter true --output_dir "%~1\.." "%~1.wav"
del "%~1.wav"
powershell -command "Get-Content "^""%~1.srt"^"" -encoding UTF8 | ForEach-Object { $_ -Replace '\.$', '' } | Out-File -Encoding UTF8 "^""%~1-dot-removed.srt"^"""
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment