gpt4 book ai didi

python - "RuntimeError: "slow_conv2d_cpu "not implemented for ' 一半 '"

转载 作者:行者123 更新时间:2023-12-02 17:59:40 32 4
gpt4 key购买 nike

我正在为 STT 使用 OpenAI 的新 Whisper 模型,当我尝试运行它时出现 RuntimeError: "slow_conv2d_cpu"not implemented for 'Half'

不确定

这是完整的错误:

Traceback (most recent call last):
File "/Users/reallymemorable/git/fp-stt/2-stt.py", line 20, in <module>
result = whisper.decode(model, mel, options)
File "/opt/homebrew/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/opt/homebrew/lib/python3.10/site-packages/whisper/decoding.py", line 705, in decode
result = DecodingTask(model, options).run(mel)
File "/opt/homebrew/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/opt/homebrew/lib/python3.10/site-packages/whisper/decoding.py", line 621, in run
audio_features: Tensor = self._get_audio_features(mel) # encoder forward pass
File "/opt/homebrew/lib/python3.10/site-packages/whisper/decoding.py", line 565, in _get_audio_features
audio_features = self.model.encoder(mel)
File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/homebrew/lib/python3.10/site-packages/whisper/model.py", line 148, in forward
x = F.gelu(self.conv1(x))
File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 313, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/opt/homebrew/lib/python3.10/site-packages/whisper/model.py", line 43, in _conv_forward
return super()._conv_forward(
File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 309, in _conv_forward
return F.conv1d(input, weight, bias, self.stride,
RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'

这是我的代码,但我认为问题不在这里:

import whisper

model = whisper.load_model("base")

# load audio and pad/trim it to fit 30 seconds
audio = whisper.load_audio("speech-to-text-sample.wav")
audio = whisper.pad_or_trim(audio)

# make log-Mel spectrogram and move to the same device as the model
mel = whisper.log_mel_spectrogram(audio).to(model.device)

# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}")

# decode the audio
options = whisper.DecodingOptions()
result = whisper.decode(model, mel, options)

# print the recognized text
print(result.text)

我应该如何处理依赖项中的错误数据类型错误?

最佳答案

通过将解码选项指定为 ftp16 false ,它将修复此错误

options = whisper.DecodingOptions(fp16 = False)

关于python - "RuntimeError: "slow_conv2d_cpu "not implemented for ' 一半 '",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74725439/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com