private VoiceBackend CreateBackendFor(TTSBackend backendKind) { return(backendKind switch { TTSBackend.System => new SystemBackend(this.config), TTSBackend.Websocket => new WebsocketBackend(this.config, this.sharedState), TTSBackend.AmazonPolly => new AmazonPollyBackend(this.config), _ => throw new NotImplementedException(), });
public void SetBackend(TTSBackend backendKind) { _ = Task.Run(() => { BackendLoading = true; var newBackend = CreateBackendFor(backendKind); var oldBackend = this.backend; this.backend = newBackend; BackendLoading = false; oldBackend?.Dispose(); }); }