nemo_stt_kz_quartznet15x5 / transcribe.py
transiteration's picture
Update transcribe.py
3934c3c verified
raw
history blame contribute delete
430 Bytes
import os
from pathlib import Path
import nemo.collections.asr as nemo_asr
def transcribe(audio_file):
try:
text = model_kz.transcribe([audio_file])
return text[0]
except:
return 'Try another file format.'
language = "kz"
BASE_DIR = Path(__file__).resolve(strict=True).parent
model_kz = nemo_asr.models.EncDecCTCModel.restore_from(restore_path=f"{BASE_DIR}/stt_{language}_quartznet15x5.nemo")