2

I´m trying to use Whisper model but occours an error saying:

UserWarning: FP16 is not supported on CPU; using FP32 instead warnings.warn("FP16 is not supported on CPU; using FP32 instead") file not found. exiting process.

my code:

import whisper
import os

# created this logic to get the real path to the file

current_dir = os.path.dirname(os.path.abspath(__file__))
file_name = "audio.wav"
file_path = os.path.join(current_dir, file_name)
print(file_path)

# the transcript logic:

listen = file_path

def transcribe():
    model = whisper.load_model("large")
    result = model.transcribe(listen)
    print(result["text"])
    return result

try:
    result = transcribe()
    with open("transcript.txt", "w") as file:
        file.write(result["text"])
    print("file saved")
except FileNotFoundError:
    print("file not found.")
except PermissionError:
    print("Not permitted to save file.")
except Exception as e:
    print("An unknow error occured:", str(e))
finally:
    print("exiting process.")

Thanks for now

By the way, I tried this:

current_dir = os.path.dirname(os.path.abspath(__file__))
file_name = "audio.wav"
file_path = os.path.join(current_dir, file_name)
print(file_path)

and the path by itself = "C:\Users\rene.pessoto\Desktop\Audio\audio.wav" and ("C:\Users\rene.pessoto\Desktop\Audio", "audio.wav") but I can´t finish it yet.

*the file has 39 minutes and its size is 214MB

1

4 Answers 4

0

I get the same warning except the "file not found. exiting" part. But the code runs smoothly and transcription works fine. The python openai-whisper module is still working without any API, locally. We need to just install openai-whisper using pip. So there is no question about change of API.

We need to look at the output of print(file_path).

current_dir = os.path.dirname(os.path.abspath(__file__))

is only helpful if your source file is in the same folder as your audio file. If not your file wouldn't found and you'll get 'file not found' error.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

-1

Instead of using

result = model.transcribe(listen)

try to use this

options = whisper.DecodingOptions(fp16 = False)
result = whisper.decode(model, mel, options)

Comments

-1

Looks like the documentation/API may have changed since you posted this. The docs now say File uploads are currently limited to 25 MB, which could be an issue for you. The recommendation in the docs is to use openai and open before passing the file to the API, as such:

import openai
audio_file= open("/path/to/file/audio.mp3", "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)

They also recommend using AudioSegment to break up the audio file in pieces.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.