rhasspy / piper

A fast, local neural text to speech system

Home Page:https://rhasspy.github.io/piper-samples/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can it support asynchronous synthesis?

High-calcium-tiger opened this issue · comments

I find function synthesis use session.onnx.Run() to synthesis audio data in piper.cpp line386.
this is synchronous. I want asynchronous to synthesis audio data.

I find function RunAsync() in onnxruntime_cxx_api.h in onnxruntime-main project source code.
Can I understand that switching to this function will enable asynchronous support?
Can give me a pitch fo asynchronous to synthesis audio data?
thank you.

Let me join the question.
I am using piper as library in my Qt/C++ programm. Using Qt's Qt::Concurrent::run API I can easilly start piper's textToAudio function in separate thread and get result once function finished. However this doesn't support cancellation. So in case of interruption computation of textToAudio function still going till the end.

Maybe there is an option to run this function in a manner of cycle? And on each iteration to check interruption flag and, optionally, signal progress.

I think what you are looking for is demonstrated in this example:
https://github.com/rhasspy/piper/blob/master/src/python/piper_train/infer_onnx_streaming.py

You'll need to export the model in two parts: encoder and decoder
https://github.com/rhasspy/piper/blob/master/src/python/piper_train/export_onnx_streaming.py

@MikePooh I want Streaming synthesis.In TTS synthesizing PCM data while playing it simultaneously can reduce latency. There is no need to wait for the PCM synthesis to complete before playing it.
@geneing