import io
import logging

from .rapid_paraformer import RapidParaformer
from .rapid_paraformer.utils import read_yaml

class ASRService():

    def __init__(self, config_path: str):
        config = read_yaml(config_path)
        print(config)
        logging.info('Initializing ASR Service...')
        self.paraformer = RapidParaformer(config)

    def infer(self, wav_path):
        by = open(wav_path, 'rb')
        result = self.paraformer([io.BytesIO(by.read())])
        return result[0]
