How can I eliminate this warning: "Loading Whisper model (base)...
Transcribing audio...
C:\Users\prepa\AppData\Local\Programs\Python\Python312\Lib\site-packages\whisper\transcribe.py:126: UserWarning: FP16 is not supported on CPU; using FP32 instead
warnings.warn("FP16 is not supported on CPU; using FP32 instead")"
Assistant
The warning message you're encountering:
code
UserWarning: FP16 is not supported on CPU; using FP32 instead
is generated because the Whisper library detects that your system's CPU does not support FP16 (Float16) precision, which is typically used for faster computations on GPUs. As a result, it falls back to using FP32 (Float32) precision. This warning is informational and does not indicate any error in transcription.
However, if you'd like to eliminate this warning for a cleaner output, you can suppress it using Python's warnings module. Here's how you can do it:
Method 1: Suppress Specific Warning
You can suppress just this specific warning by filtering warnings that match the warning message. Here's an example:
python
import warnings
import whisper
# Suppress the specific FP16 warning
warnings.filterwarnings(
"ignore",
message="FP16 is not supported on CPU; using FP32 instead",
category=UserWarning
)
# Load the Whisper model and transcribe
model = whisper.load_model("base")
transcription = model.transcribe("audiofile.wav")
print(transcription["text"])
Method 2: Use a Context Manager
If you prefer to suppress the warning only for a specific block of code, you can use a context manager:
python
import warnings
import whisper
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message="FP16 is not supported on CPU; using FP32 instead",
category=UserWarning
)
model = whisper.load_model("base")
# Proceed with transcription without the warning
transcription = model.transcribe("audiofile.wav")
print(transcription["text"])
Method 3: Suppress All UserWarnings (Not Recommended)
If you want to suppress all UserWarning messages (not just the FP16 warning), you can do so, but this is generally not recommended as it might hide other important warnings:
python
import warnings
import whisper
# Suppress all UserWarnings
warnings.simplefilter("ignore", UserWarning)
# Load the model and transcribe
model = whisper.load_model("base")
transcription = model.transcribe("audiofile.wav")
print(transcription["text"])
Additional Considerations
Check for Updates: Ensure you're using the latest version of the Whisper library, as updates might handle such warnings differently or offer configuration options to manage them.
Hardware Upgrade: If you frequently work with models that benefit from FP16 precision and require faster computation, consider using a GPU that supports FP16. This would not only eliminate the warning but also potentially speed up your transcription tasks.
Understand the Impact: While suppressing warnings can lead to a cleaner output, always make sure that the warnings are genuinely non-impactful for your application to avoid missing out on important information.
By implementing one of the suppression methods above, you should no longer see the FP16 warning when using the Whisper model on your CPU.
Example Code with Specific Warning Suppression:
python
import warnings
import whisper
# Suppress the specific FP16 warning
warnings.filterwarnings(
"ignore",
message="FP16 is not supported on CPU; using FP32 instead",
category=UserWarning
)
# Load the model and perform transcription
model = whisper.load_model("base")
result = model.transcribe("your_audio_file.wav")
print(result["text"])
This approach ensures that only the targeted warning is suppressed, keeping other warnings visible for your awareness.