rhasspy / piper

A fast, local neural text to speech system
https://rhasspy.github.io/piper-samples/
MIT License
4.37k stars 297 forks source link

stopping speech? #437

Open tvraman opened 2 months ago

tvraman commented 2 months ago

Is there a call to stop speech once synthesis has started, other than chopping it off at the knees by killing the audio player?

jn64 commented 1 month ago

What do you mean by "call"?

If you are piping the output of piper to your audio player (as in the streaming audio example), then kill the whole thing (Ctrl-c in most common shells). Technically, you can kill the audio player (e.g. pkill aplayer in another terminal), which will close the pipe and cause piper to also terminate.

If you are writing to a file / not streaming the output in real-time, then naturally just kill piper.

tvraman commented 1 month ago

The problem is not with the killing the whole pipeline. The problem is that if that's the only way to stop speech, then the next utterance requires the whole engine to start up again, and that implies latency; not a huge problem for Home Assistant like uses, but not acceptable for projects like Emacspeak that provide auditory feedback for all of one's actions

--

jn64 commented 1 month ago

Well, that's a completely different problem from your initial question.

See #376, #90

beqabeqa473 commented 1 month ago

No, it is not different problem.

@tvraman is correct.

I think the simple fix would be to return from callback and if return code will be not 0, stop synthesis of next utterance.

@synesthesiam what do you think about that?

jn64 commented 1 month ago

Of course it's a different problem. "How to stop synthesis" (Ctrl-c, kill, pkill, various TUI/GUI task managers) is different from "how to stop synthesis and continue using the same instance of Piper to synthesise multiple times, to reduce startup latency".

The latter might be better discussed in the context of #376.