The code seems fine. The first and foremost problem is that your machine might lack either software or hardware necessary for whisper to work. See this whisper AI error : FP16 is not supported on CPU; using FP32 instead