void SelectLanguageSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { var selectedLanguage = languages[e.Position]; var lang = SupportedLanguage.FromLanguageTag(selectedLanguage.LanguageCode); var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d", selectedLanguage.AccessToken, lang); if (aiService != null) { aiService.Cancel(); } aiService = new SpeaktoitRecognitionService(this, config); aiService.OnResult += AiService_OnResult; aiService.OnError += AiService_OnError; aiService.ListeningStarted += AiService_ListeningStarted; aiService.ListeningFinished += AiService_ListeningFinished; aiService.AudioLevelChanged += AiService_AudioLevelChanged; }
private void InitializeService(LanguageConfig conf) { var lang = SupportedLanguage.FromLanguageTag(conf.LanguageCode); var config = new AIConfiguration(conf.AccessToken, lang); //TODO: Option for verbose logging. Remove this line in production. config.DebugLog = true; if (aiService != null) { aiService.Cancel(); } aiService = AIService.CreateService(config); aiService.OnResult += AiService_OnResult; aiService.OnError += AiService_OnError; aiService.ListeningStarted += AiService_ListeningStarted; aiService.ListeningFinished += AiService_ListeningFinished; aiService.AudioLevelChanged += AiService_AudioLevelChanged; }
private void InitializeService(LanguageConfig conf) { var lang = SupportedLanguage.FromLanguageTag(conf.LanguageCode); var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d", conf.AccessToken, lang); config.JsonProcessingWithoutDynamicCode = true; config.DebugLog = true; if (aiService != null) { aiService.Cancel(); } aiService = new SpeaktoitRecognitionService(config); aiService.OnResult += AiService_OnResult; aiService.OnError += AiService_OnError; aiService.ListeningStarted += AiService_ListeningStarted; aiService.ListeningFinished += AiService_ListeningFinished; aiService.AudioLevelChanged += AiService_AudioLevelChanged; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddSingleton(Configuration.GetSection("BotConfiguration").GetSection("Telegram").Get <TelegramBotConfiguration>()); services.AddSingleton <IBotService, BotService>(); services.AddSingleton <IActionController <AddPokemonFilterAction>, AddPokemonFilterActionController>(); services.AddSingleton <IActionController <NearestPokemonAction>, NearestPokemonActionController>(); services.AddSingleton <IActionController <GymStateAction>, GymStateActionController>(); services.AddSingleton <IActionResponseController <AddPokemonFilterActionResponse>, AddPokemonFilterActionResponseController>(); services.AddSingleton <IActionResponseController <NearestPokemonActionResponse>, NearestPokemonActionResponseController>(); services.AddSingleton <IActionResponseController <GymStateActionResponse>, GymStateActionResponseController>(); services.AddSingleton <IPokemonFilterService, LogPokemonFilterService>(); services.AddSingleton <INearestPokemonService, FakeNearestPokemonService>(); services.AddSingleton <IGymIdByNameService, FakeGymIdByNameService>(); services.AddSingleton <IGymStateService, FakeGymStateService>(); services.AddSingleton <FightCountService, FightCountService>(); services.AddSingleton <IMessageService <AddPokemonFilterActionResponse>, AddPokemonFilterMessageService>(); services.AddSingleton <IMessageService <NearestPokemonActionResponse>, PokemonSpawnMessageService>(); services.AddSingleton <IMessageService <GymStateActionResponse>, GymStateMessageService>(); services.AddSingleton <IBotMessageController, BotMessageController>(); services.AddSingleton <AiResponseToActionService, AiResponseToActionService>(); services.AddSingleton <PokemonFilterMapping, PokemonFilterMapping>(); services.AddSingleton <NearestPokemonMapping, NearestPokemonMapping>(); services.AddSingleton <GymStateMapping, GymStateMapping>(); var apiAiConfig = Configuration.GetSection("ApiAiConfiguration").Get <ApiAiConfiguration>(); var config = new AIConfiguration(apiAiConfig.AccessToken, SupportedLanguage.FromLanguageTag(apiAiConfig.LanguageTag)); var apiAi = new ApiAi(config); services.AddSingleton(apiAi); }
void SelectLanguageSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { var selectedLanguage = languages[e.Position]; var lang = SupportedLanguage.FromLanguageTag(selectedLanguage.LanguageCode); var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d", selectedLanguage.AccessToken, lang); //TODO: Option for verbose logging. Remove this line in production. config.DebugLog = true; if (aiService != null) { aiService.Cancel(); } aiService = AIService.CreateService(this, config, RecognitionEngine.ApiAi); aiService.OnResult += AiService_OnResult; aiService.OnError += AiService_OnError; aiService.ListeningStarted += AiService_ListeningStarted; aiService.ListeningFinished += AiService_ListeningFinished; aiService.AudioLevelChanged += AiService_AudioLevelChanged; }