File "tttttttttttttt.py", line 44, in speech_to_text logits = model(input_values).logits RuntimeError: expected scalar type Long but found Float?
时间: 2024-02-12 08:05:06 浏览: 66
这个错误信息提示中也出现了类型错误的问题,期望输入的类型为 Long 类型,但是实际输入的是 Float 类型。可以尝试将 `input_values` 转换为 LongTensor 类型,代码如下:
```
input_values = tokenizer(audio, return_tensors="pt", sampling_rate=16000).input_values
input_values = input_values.type(torch.LongTensor)
```
这样应该可以解决出现的类型错误问题。
相关问题
model = deepspeech.Model(model_path, beam_width) Exception ignored in: <function Model.del at 0x00000222FFA53430> Traceback (most recent call last): File "C:\Python-64bit\lib\site-packages\deepspeech_init_.py", line 42, in del if self._impl: AttributeError: 'Model' object has no attribute '_impl' Traceback (most recent call last): File "tttttttttttttt.py", line 6, in <module> model = deepspeech.Model(model_path, beam_width) TypeError: init() takes 2 positional arguments but 3 were given
这个错误的原因是您给 `deepspeech.Model()` 函数传递了多余的参数。`deepspeech.Model()` 函数只需要一个参数,即 DeepSpeech 模型的路径。您需要检查一下您的代码,看看是否有其他地方也给该函数传递了参数。您可以尝试修改代码如下所示:
```
model = deepspeech.Model(model_path)
```
这应该可以解决这个问题。
阅读全文