0

After running my program, I am getting a Output, but I also get this error message.

Exception ignored in: <function Model.__del__ at 0x7f02ba33b430>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/deepspeech/__init__.py", line 43, in __del__
AttributeError: 'NoneType' object has no attribute 'impl'

Here is the code - Here I am trying to convert an wv audio file into text using deepspeech library.

from deepspeech import Model
import numpy as np
import os
import wave
import json

from IPython.display import Audio
from IPython.display import clear_output

model_file_path = 'deepspeech-0.8.2-models.pbmm'
lm_file_path = 'deepspeech-0.8.2-models.scorer'
beam_width = 100
lm_alpha = 0.93
lm_beta = 1.18

model = Model(model_file_path)
model.enableExternalScorer(lm_file_path)

model.setScorerAlphaBeta(lm_alpha, lm_beta)
model.setBeamWidth(beam_width)


def read_wav_file(filename):
    with wave.open(filename, 'rb') as w:
        rate = w.getframerate()
        frames = w.getnframes()
        buffer = w.readframes(frames)

    return buffer, rate



def transcribe(audio_file):
    buffer, rate = read_wav_file(audio_file)
    data16 = np.frombuffer(buffer, dtype=np.int16)

    
    return model.stt(data16)


print(transcribe('speech.wav'))
  • DeepSpeech is in an early development phase. You didn't give any indication what version you are using (also 0.8?). Please head over to their Discourse and report some more information: https://discourse.mozilla.org/t/what-and-how-to-report-if-you-need-support/62071 – Olaf Jan 12 '21 at 08:24
  • Hello, I am using version 0.8.2 – Ayush Kabra Jan 12 '21 at 08:28
  • Sorry, this was just an example. You obviously didn't read the link. Just check the code in the repo to know more about your problem. – Olaf Jan 12 '21 at 08:30

1 Answers1

0

Importing IPython is causing the issue, try running your code without it and it should work.

from deepspeech import Model
import numpy as np
import os
import wave
import json

model_file_path = 'deepspeech-0.8.2-models.pbmm'
lm_file_path = 'deepspeech-0.8.2-models.scorer'
beam_width = 100
lm_alpha = 0.93
lm_beta = 1.18

model = Model(model_file_path)
model.enableExternalScorer(lm_file_path)

model.setScorerAlphaBeta(lm_alpha, lm_beta)
model.setBeamWidth(beam_width)


def read_wav_file(filename):
    with wave.open(filename, 'rb') as w:
        rate = w.getframerate()
        frames = w.getnframes()
        buffer = w.readframes(frames)

    return buffer, rate



def transcribe(audio_file):
    buffer, rate = read_wav_file(audio_file)
    data16 = np.frombuffer(buffer, dtype=np.int16)

    
    return model.stt(data16)


print(transcribe('speech.wav'))
Zeke John
  • 79
  • 1
  • 7