Created
January 26, 2023 23:05
-
-
Save spencerkittleson/7cf4c194518e9205443ddebde636cda7 to your computer and use it in GitHub Desktop.
Mimic3Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace UserTriggerTextToSpeech | |
{ | |
public class Mimic3Service | |
{ | |
private static readonly HttpClient _client = new(); | |
private readonly Uri _url = new("http://127.0.0.1:59125"); | |
public Mimic3Service() { | |
} | |
public async Task<Stream> ConvertTts(string text) { | |
await CheckInstance(); | |
var result = await _client.PostAsync($"{_url}/api/tts", new StringContent(text)); | |
return await result.Content.ReadAsStreamAsync(); | |
} | |
private async Task CheckInstance() { | |
var result = await _client.GetAsync(_url); | |
if (!result.IsSuccessStatusCode) { | |
throw new Exception("Mimic3 web server is not found. https://github.com/MycroftAI/mimic3 . Or https://hub.docker.com/r/mycroftai/mimic3 then `docker run -p 59125:59125 mycroftai/mimic3`"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment