k2-fsa / sherpa-onnx

Speech-to-text, text-to-speech, speaker diarization, and VAD using next-gen Kaldi with onnxruntime without Internet connection. Support embedded systems, Android, iOS, Raspberry Pi, RISC-V, x86_64 servers, websocket server/client, C/C++, Python, Kotlin, C#, Go, NodeJS, Java, Swift, Dart, JavaScript, Flutter, Object Pascal, Lazarus, Rust
https://k2-fsa.github.io/sherpa/onnx/index.html
Apache License 2.0
3.61k stars 421 forks source link

请问通过Python来调用offline的模型具体怎么调用? #916

Closed zhanweiw closed 5 months ago

zhanweiw commented 5 months ago

请问如下命令,想通过Python来调用,具体如何实现?谢谢!

sherpa-onnx-offline --num-threads=10 --tokens=./sherpa-onnx-paraformer-zh-2024-03-09/tokens.txt --paraformer=./sherpa-onnx-paraformer-zh-2024-03-09/model.onnx ./sherpa-onnx-paraformer-zh-2024-03-09/test_wavs/0.wav 
csukuangfj commented 5 months ago

请看python-api-examples 目录。例子一看一大把

zhanweiw commented 5 months ago

看了,没找到microphone + offline的例子。看下边API的定义,需要encoder + decoder + joiner三个onnx模型,但上边的命令行只有一个onnx模型嘛。

    def from_transducer(
        cls,
        encoder: str,
        decoder: str,
        joiner: str,
        tokens: str,
        num_threads: int = 1,
        sample_rate: int = 16000,
        feature_dim: int = 80,
        decoding_method: str = "greedy_search",
        max_active_paths: int = 4,
        hotwords_file: str = "",
        hotwords_score: float = 1.5,
        blank_penalty: float = 0.0,
        modeling_unit: str = "cjkchar",
        bpe_vocab: str = "",
        debug: bool = False,
        provider: str = "cpu",
        model_type: str = "transducer",
    )
zhanweiw commented 5 months ago

我应用调用"from_paraformer"这个函数对吧?

csukuangfj commented 5 months ago

对的

都有的。

请看examples