Spaces:
Runtime error
Runtime error
File size: 730 Bytes
955603e 3eff449 955603e 3eff449 955603e 3eff449 955603e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import os
from pathlib import Path
import nemo.collections.asr as nemo_asr
# def converter(audio_file):
# converted = audio_file.split(".")[0] + "converted_.wav"
# cmd_str = f"ffmpeg -y -i {audio_file} -ac 1 -ar 16000 {converted}"
# os.system(cmd_str)
# # os.remove(audio_file)
# return converted
def transcribe(audio_file):
# wav_file = converter(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")
|