python Deepspeech TypeError:\uuuu init\uuuuu()接受2个位置参数,但给出了3个
我正在尝试实现deepspeech,作为实现的一部分,我正在尝试运行以下代码。我已经安装了python Deepspeech TypeError:\uuuu init\uuuuu()接受2个位置参数,但给出了3个,python,python-3.x,mozilla-deepspeech,Python,Python 3.x,Mozilla Deepspeech,我正在尝试实现deepspeech,作为实现的一部分,我正在尝试运行以下代码。我已经安装了python3和deepspeech-0.9.3 运行下面的代码时,我在model=deepspeech.model(model_FILE_PATH,BEAM_WIDTH)TypeError中得到一个错误,第17行是错误:\uuuu init_uu()接受2个位置参数,但给出了3个 import deepspeech import numpy as np import os import pyaudio i
python3
和deepspeech-0.9.3
运行下面的代码时,我在model=deepspeech.model(model_FILE_PATH,BEAM_WIDTH)TypeError中得到一个错误,第17行是错误:\uuuu init_uu()接受2个位置参数,但给出了3个
import deepspeech
import numpy as np
import os
import pyaudio
import time
# DeepSpeech parameters
DEEPSPEECH_MODEL_DIR = 'deepspeech-0.9.3-models'
MODEL_FILE_PATH = os.path.join(DEEPSPEECH_MODEL_DIR, 'output_graph.pbmm')
BEAM_WIDTH = 500
LM_FILE_PATH = os.path.join(DEEPSPEECH_MODEL_DIR, 'lm.binary')
TRIE_FILE_PATH = os.path.join(DEEPSPEECH_MODEL_DIR, 'trie')
LM_ALPHA = 0.75
LM_BETA = 1.85
# Make DeepSpeech Model
model = deepspeech.Model(MODEL_FILE_PATH, BEAM_WIDTH)
model.enableDecoderWithLM(LM_FILE_PATH, TRIE_FILE_PATH, LM_ALPHA, LM_BETA)
# Create a Streaming session
context = model.createStream()
# Encapsulate DeepSpeech audio feeding into a callback for PyAudio
text_so_far = ''
def process_audio(in_data, frame_count, time_info, status):
global text_so_far
data16 = np.frombuffer(in_data, dtype=np.int16)
model.feedAudioContent(context, data16)
text = model.intermediateDecode(context)
if text != text_so_far:
print('Interim text = {}'.format(text))
text_so_far = text
return (in_data, pyaudio.paContinue)
# PyAudio parameters
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
CHUNK_SIZE = 1024
# Feed audio to deepspeech in a callback to PyAudio
audio = pyaudio.PyAudio()
stream = audio.open(
format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK_SIZE,
stream_callback=process_audio
)
print('Please start speaking, when done press Ctrl-C ...')
stream.start_stream()
try:
while stream.is_active():
time.sleep(0.1)
except KeyboardInterrupt:
# PyAudio
stream.stop_stream()
stream.close()
audio.terminate()
print('Finished recording.')
# DeepSpeech
text = model.finishStream(context)
print('Final text = {}'.format(text))
您正在使用不推荐使用的代码。 您正在尝试使用0.9模型和0.6代码。从0.7开始,语言模型不再使用lm.binary和trie。你的代码还有很多错误
根据您的用例,可能会使用其中一个。您要么提供了更多参数,要么没有在init中使用self关键字。虽然可能是真的,但这根本不能回答问题是的,但他要么使用了他没有的旧模型,要么切换到了新代码。但是像lms这样的其他参数不起作用。因此,简单的“这样做”是行不通的。他必须检查手册。请在发布前搜索您的错误消息