import whisper
from zhconv import convert


def get_whisper_asr(audio, model='medium'):
    try:
        model = whisper.load_model(model, device='cuda')
        result = model.transcribe(audio, language='Chinese')
        # 简繁转换
        # zh-cn 大陆简体
        # zh-hant 繁体
        return convert(result['text'], 'zh-cn')
    except Exception as e:
        print(f'asr error: {audio}. e: {e}')
        return ''
