erew123 / alltalk_tts

AllTalk is based on the Coqui TTS engine, similar to the Coqui_tts extension for Text generation webUI, however supports a variety of advanced features, such as a settings page, low VRAM support, DeepSpeed, narrator, model finetuning, custom models, wav file maintenance. It can also be used with 3rd Party software via JSON calls.
GNU Affero General Public License v3.0
1.17k stars 124 forks source link

Trying to use streaming endpoint in C# ConsoleApp #192

Closed RenNagasaki closed 7 months ago

RenNagasaki commented 7 months ago

@erew123 Sorry to impose on you again. I'm currently trying to use your streaming endpoint -> http://localhost:7851/api/tts-generate-streaming I successfully managed to request a generation but I fail to play the generated file. image

When I open the url manually I get a small Audio Player, could this be the issue?

Is there like a raw endpoint which just returns the audio stream?

RenNagasaki commented 7 months ago

Just found out that the resulting .wav file can't be played via WMP. VLC works but not WMP. Any ideas why? An online file analyzer gets this from the file: image

RenNagasaki commented 7 months ago

I've got it all sorted out now.

Finished code for others who are interested:

`var uriBuilder = new UriBuilder(UrlBase) { Path = Path }; var query = HttpUtility.ParseQueryString(uriBuilder.Query); query["text"] = text; query["voice"] = voice + ".wav"; query["language"] = getAlltalkLanguage(language); query["output_file"] = "ignoreme.wav"; //query["autoplay"] = "true"; uriBuilder.Query = query.ToString();

using (var wc = new System.Net.WebClient()) { wc.Proxy = null; var stream = wc.OpenRead(uriBuilder.Uri); var s = new RawSourceWaveStream(stream, new WaveFormat(24000, 16, 1)); var soundOut = new WasapiOut(); //soundOut.PlaybackStopped += (, ) => { this.speechCompleted.Set(); }; soundOut.Init(s); soundOut.Volume = volume; soundOut.Play(); }`