OpenAI Whisper
Python 3.8.6
Guide on how to use OpenAI's Whisper speech recognition model with Python.
Installation
- Download FFmpeg 'ffmpeg-master-latest-win64-gpl.zip' from https://github.com/BtbN/FFmpeg-Builds/releases
- Unzip the downloaded file and move the its content to a directory of your choice (e.g.,
C:\path\bin
). - Add the directory where
ffmpeg.exe
is located to theUser variables for User
Path
environment variable.
Check in CMD of IDE terminal 'ffmpeg -version':
...
libavutil 58. 6.100 / 58. 6.100
libavcodec 60. 9.100 / 60. 9.100
libavformat 60. 4.101 / 60. 4.101
libavdevice 60. 2.100 / 60. 2.100
libavfilter 9. 5.100 / 9. 5.100
libswscale 7. 2.100 / 7. 2.100
libswresample 4. 11.100 / 4. 11.100
libpostproc 57. 2.100 / 57. 2.100
...
Usage
- Install the
ffmpeg-python
package by runningpip install ffmpeg-python
. - Load the Whisper model and transcribe an audio file by running the following code:
import whisper
model = whisper.load_model("base")
result = model.transcribe("audio.mp3")
print(result["text"])
References
- OpenAI Whisper: https://github.com/openai/whisper
- Hub for installing OpenAI Whisper: https://hub.tcno.co/ai/whisper/install/
- How to run OpenAI's Whisper speech recognition model: https://www.assemblyai.com/blog/how-to-run-openais-whisper-speech-recognition-model/
- https://www.assemblyai.com/blog/how-to-run-openais-whisper-speech-recognition-model/
- Download FFmpeg: https://ffmpeg.org/download.html#build-windows
- https://platform.openai.com/docs/libraries
- https://github.com/openai/openai-node