#!/usr/bin/python3
# -*- coding: utf-8 -*-
import argparse

from gradio_client import Client, file

from project_settings import project_path


def get_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--filename",
        default=(project_path / "data/test_wavs/paraformer-zh/si_chuan_hua.wav").as_posix(),
        type=str
    )
    args = parser.parse_args()
    return args


def main():
    args = get_args()

    filename = args.filename

    client = Client("https://qgyd2021-asr.hf.space/")
    result = client.predict(
        language="Chinese",
        repo_id="csukuangfj/wenet-chinese-model",
        decoding_method="greedy_search",
        num_active_paths=4,
        add_punctuation="Yes",
        in_filename=file(filename),
        api_name="/partial"
    )
    transcript, note = result
    print(transcript)

    return


if __name__ == '__main__':
    main()