Pyscript issue

/config/pyscript/stt.py

import speech_recognition as sr

@service
def status(filename="audio.wav"):
  # initialize the recognizer
  r = sr.Recognizer()
  # open the file
  with sr.AudioFile(filename) as source:
    # listen for the data (load audio to memory)
    audio_data = r.record(source)
    # recognize (convert from speech to text)
    text = r.recognize_google(audio_data)
    log.info(text)

/config/pyscript/requirements.txt

SpeechRecognition
pydub

“audio.wav” is in /config/pyscript.

When I run the service, however, I get

Exception in <file.stt.status> line 8: with sr.AudioFile(filename) as source: ^ AttributeError: ‘NoneType’ object has no attribute ‘close’

Any ideas?