WarmUpTill / SceneSwitcher

An automation tool for OBS Studio
https://obsproject.com/forum/resources/automatic-scene-switching.395/
GNU General Public License v2.0
967 stars 76 forks source link

[Feature Request] Use TTS with Twitch Reward Points #912

Closed themegaxandy closed 10 months ago

themegaxandy commented 11 months ago

Is your feature request related to a problem? Please describe. image It would be interesting if there was an action to use TTS in this plugin.

Describe the solution you'd like Windows itself has its built-in TTS, which could be used here, so that it would not depend on the internet and a cloud solution. According to an article on another site, it is possible to generate TTS on Windows using these commands:

Describe alternatives you've considered I tried using the plugin's "Run" action, but I was unsuccessful in generating the TTS, although I was successful in a normal CMD window.

Destroy666x commented 11 months ago

That's what I also was looking at a bit for the same reason. And this definitely should work: image assuming you got PowerShell 7 installed. To be safe, also remove quotes from variable first.

I'm not too sure how viable a separate TTS action is, though. As this would need to be cross-system, so Microsoft-related solutions won't be enough and I'm not too sure there are similar readily available tools for Linux/Mac.

So this would need to be done through something like https://github.com/rhasspy/piper which is cross-system and supports bunch of languages/voices. I plan to play with it and Run locally to see how it performs on weekend.

themegaxandy commented 11 months ago

@Destroy666x Now I was able to use the TTS to work through the plugin's "Run" action. I didn't know the arguments were supposed to be separated like that.

However, I am having difficulty capturing the audio coming from the new powershell process. In OBS, I don't use capture all audio from my computer, but rather application audio capture. It does not appear in the dropdown menu list, and even if you manually define the exe through the plugin itself, no audio is captured.

Destroy666x commented 11 months ago

@themegaxandy are you using win-audio-capture plugin? That's still better in terms of separating sound. I'm not sure how to catch PowerShell with that as I haven't messed with that yet. but I'll let you know once I find out. I assume OBS/Switcher spawns a separate process for that or at least I hope.

themegaxandy commented 11 months ago

@Destroy666x Yes, it starts a new process, and appears within the OBS Studio process in the Task Manager. And I'm using OBS's native application audio capture.

Destroy666x commented 11 months ago

If it's new process under OBS then the plugin should help as it shows OBS while the in-built one doesn't. I quickly checked and I don't see a specific PowerShell subprocess though, so might be impossible to separate just TTS.

Unless...

There's also a way to start new processes with e.g. cmd /C cmd in Windows, that could help, if it works with Switcher. You could try.

themegaxandy commented 11 months ago

I found a way to do it using Piper, the tool @Destroy666x mentioned.

All I did was use the plugin to write the TTS message to a text.txt file. Then I used the Run action to run a speak.bat file. This file contains the following content: piper --model <voice model file here>.onnx --output-raw < text.txt | "C:/Program Files (x86)/VideoLAN/VLC/vlc.exe" --play-and-exit --demux=rawaud --rawaud-channels=1 --rawaud-samplerate=22050 --rawaud-fourcc= s16l -.

Basically this .bat file will tell Piper to stream the speech synthesis of whatever is in this text.txt file to VLC, in which OBS will be capturing the audio as soon as VLC is opened (the VLC UI has to appear, otherwise OBS will not be able to capture the audio).

It's a bit of a workaround, but it was the way I managed to make it work, as I couldn't make the plugin's Run action work because of the "|" character. I don't really understand how it works, nor why I have to put each argument separately in the plugin. If anyone knows how to make it work, I'd be grateful to know, because then I wouldn't need a text.txt file, nor a speak.bat file.