Skip to content

Commit

Permalink
Merge pull request microsoft#84 from gsegares/update-sdk
Browse files Browse the repository at this point in the history
Updating lab implementation
  • Loading branch information
tarasha authored Feb 22, 2019
2 parents f9abb0f + 7dace76 commit 2d73a99
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 94 deletions.
128 changes: 62 additions & 66 deletions BuildAnIntelligentBot/readme.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified BuildAnIntelligentBot/resources/restaurant-lab.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion BuildAnIntelligentBot/resources/talk-to-my-bot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"luis_schema_version": "3.0.0",
"versionId": "0.1",
"versionId": "0.2",
"name": "talk-to-my-bot",
"desc": "",
"culture": "en-us",
Expand Down
16 changes: 8 additions & 8 deletions BuildAnIntelligentBot/src/ChatBot/ChatBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<CodeAnalysisRuleSet>EchoBotWithCounter.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>EchoBot.ruleset</CodeAnalysisRuleSet>
<TypeScriptToolsVersion>3.0</TypeScriptToolsVersion>
<UserSecretsId>f3d727f8-7445-4ccc-bf6c-13d77aea7e32</UserSecretsId>
</PropertyGroup>
Expand All @@ -24,7 +24,7 @@


<ItemGroup>
<Content Include="BotConfiguration.bot">
<Content Include="EchoBot.bot">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\carbonara.jpg">
Expand All @@ -47,13 +47,13 @@
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.7" />
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.0.8" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.0.7" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Builder.PersonalityChat" Version="4.0.0-alpha-m1.0" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.0.8" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.0.8" />
<PackageReference Include="Microsoft.Bot.Schema" Version="4.0.8" />
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.0.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Schema" Version="4.2.2" />
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.1.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="all" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace ChatBot
/// <see cref="IStatePropertyAccessor{T}"/> object are created with a singleton lifetime.
/// </summary>
/// <seealso cref="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-2.1"/>
public class EchoWithCounterBot : IBot
public class EchoBot : IBot
{
private readonly EchoBotAccessors _accessors;
private readonly ILogger _logger;
Expand All @@ -36,19 +36,19 @@ public class EchoWithCounterBot : IBot
private readonly BotServices _services;

/// <summary>
/// Initializes a new instance of the <see cref="EchoWithCounterBot"/> class.
/// Initializes a new instance of the <see cref="EchoBot"/> class.
/// </summary>
/// <param name="accessors">A class containing <see cref="IStatePropertyAccessor{T}"/> used to manage state.</param>
/// <param name="loggerFactory">A <see cref="ILoggerFactory"/> that is hooked to the Azure App Service provider.</param>
/// <seealso cref="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1#windows-eventlog-provider"/>
public EchoWithCounterBot(BotServices services, EchoBotAccessors accessors, ILoggerFactory loggerFactory, IOptions<MySettings> config)
public EchoBot(BotServices services, EchoBotAccessors accessors, ILoggerFactory loggerFactory, IOptions<MySettings> config)
{
if (loggerFactory == null)
{
throw new System.ArgumentNullException(nameof(loggerFactory));
}

_logger = loggerFactory.CreateLogger<EchoWithCounterBot>();
_logger = loggerFactory.CreateLogger<EchoBot>();
_logger.LogTrace("EchoBot turn start.");
_accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors));
}
Expand Down
2 changes: 1 addition & 1 deletion BuildAnIntelligentBot/src/ChatBot/EchoBotAccessors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ChatBot
{
/// <summary>
/// This class is created as a Singleton and passed into the IBot-derived constructor.
/// - See <see cref="EchoWithCounterBot"/> constructor for how that is injected.
/// - See <see cref="EchoBot"/> constructor for how that is injected.
/// - See the Startup.cs file for more details on creating the Singleton that gets
/// injected into the constructor.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ChatBot.Middlewares
{
public class TranslatorSpeechMiddleware : IMiddleware
{
private readonly SpeechTranslationService _speechTranslationService;
private readonly TranslatorSpeechService _translatorSpeechService;
private readonly TranslatorTextService _translatorTextService;
private readonly TextToSpeechService _textToSpeechService;

Expand All @@ -31,7 +31,7 @@ public TranslatorSpeechMiddleware(string speechKey, string translatorKey, string
}

this._translatorTextService = new TranslatorTextService(translatorKey);
this._speechTranslationService = new SpeechTranslationService(speechKey, region);
this._translatorSpeechService = new TranslatorSpeechService(speechKey, region);
this._textToSpeechService = new TextToSpeechService();
}

Expand Down Expand Up @@ -95,7 +95,7 @@ private async Task TranslateMessageAsync(ITurnContext turnContext, IMessageActiv
// STT target language will be English for this lab
if (!string.IsNullOrEmpty(audioUrl) && string.IsNullOrEmpty(text))
{
var transcript = await this._speechTranslationService.SpeechToTranslatedTextAsync(audioUrl, conversationLanguage, BotConstants.EnglishLanguage);
var transcript = await this._translatorSpeechService.SpeechToTranslatedTextAsync(audioUrl, conversationLanguage, BotConstants.EnglishLanguage);
if (transcript != null)
{
text = transcript.Translation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private KeyValuePair<string, string> GetLocaleVoiceName(string language, string
}
else
{
dictionary["en"] = new KeyValuePair<string, string>("en-US", $"{prefix} (en-US, JessaRUS)");
dictionary["en"] = new KeyValuePair<string, string>("en-US", $"{prefix} (en-US, JessaNeural)");
dictionary["es"] = new KeyValuePair<string, string>("es-ES", $"{prefix} (es-ES, Laura, Apollo)");
dictionary["fr"] = new KeyValuePair<string, string>("fr-FR", $"{prefix} (fr-FR, Julie, Apollo)");
dictionary["de"] = new KeyValuePair<string, string>("de-DE", $"{prefix} (de-DE, Hedda)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ChatBot.Services
{
public class SpeechTranslationService
{
public class TranslatorSpeechService
{

private readonly string _region;
private readonly string _subscriptionKey;

public SpeechTranslationService(string speechKey, string region)
public TranslatorSpeechService(string speechKey, string region)
{
_region = region;
_subscriptionKey = speechKey;
Expand Down
6 changes: 3 additions & 3 deletions BuildAnIntelligentBot/src/ChatBot/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public void ConfigureServices(IServiceCollection services)
var botFilePath = Configuration.GetSection("botFilePath")?.Value;

// Loads .bot configuration file and adds a singleton that your Bot can access through dependency injection.
var botConfig = BotConfiguration.Load(botFilePath ?? @".\BotConfiguration.bot", secretKey);
var botConfig = BotConfiguration.Load(botFilePath ?? @".\EchoBot.bot", secretKey);
services.AddSingleton(sp => botConfig ?? throw new InvalidOperationException($"The .bot config file could not be loaded. ({botConfig})"));

// Initialize Bot Connected Services clients.


services.AddBot<EchoWithCounterBot>(options =>
services.AddBot<EchoBot>(options =>
{
// Retrieve current endpoint.
var environment = _isProduction ? "production" : "development";
Expand All @@ -79,7 +79,7 @@ public void ConfigureServices(IServiceCollection services)
options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword);

// Creates a logger for the application to use.
ILogger logger = _loggerFactory.CreateLogger<EchoWithCounterBot>();
ILogger logger = _loggerFactory.CreateLogger<EchoBot>();

// Catches any errors that occur during a conversation turn and logs them.
options.OnTurnError = async (context, exception) =>
Expand Down
2 changes: 1 addition & 1 deletion BuildAnIntelligentBot/src/ChatBot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"botFilePath": "BotConfiguration.bot",
"botFilePath": "EchoBot.bot",
"botFileSecret": "",
"VoiceFontName": "",
"VoiceFontLanguage": "",
Expand Down
2 changes: 1 addition & 1 deletion BuildAnIntelligentBot/src/ChatBot/wwwroot/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ <h1>Bot Recognition API Settings</h1>
const speechSynthesizer = new CognitiveServices.SpeechSynthesizer({
subscriptionKey: speechSubscriptionKey,
customVoiceEndpointUrl:
'https://westus.tts.speech.microsoft.com/cognitiveservices/v1',
'https://eastus.tts.speech.microsoft.com/cognitiveservices/v1',
});
let lastSpokenConversationId = null;

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 2d73a99

Please sign in to comment.