Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions AdaptiveRemote.Speech.Tests/AdaptiveRemote.Speech.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<RootNamespace>AdaptiveRemote</RootNamespace>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="SpeechSamples\*.wav" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\AdaptiveRemote\AdaptiveRemote.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System.Diagnostics;
#if false
Comment thread
jodavis marked this conversation as resolved.
Outdated
using System.Diagnostics;
using System.Reflection;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using AdaptiveRemote.Configuration;
using AdaptiveRemote.Services.Conversation;
using AdaptiveRemote.Utilities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace AdaptiveRemote.Services.Conversation;
namespace AdaptiveRemote.Speech.Tests;

[TestClass]
public class GrammarTests
Expand Down Expand Up @@ -119,7 +122,7 @@ public async Task StaticGrammar_TestCommand(
Log("Done waiting");

// Assert
resultTask.Should().BeComplete(because: nameof(GetFirstResult) + " should return within 2000ms");
Assert.IsTrue(resultTask.IsCompleted, "Timed out waiting for a result from speech recognition");
IRecognizedSpeech result = resultTask.Result;

Assert.AreEqual(expectedText, result.Text, nameof(result) + "." + nameof(result.Text));
Expand Down Expand Up @@ -156,7 +159,9 @@ private ISpeechRecognition CreateSut()
private IHost CreateTestHost() =>
Host.CreateDefaultBuilder()
.AddConversationSystem()
.ConfigureServices(s => s.AddSingleton<IAudioConfigurationService>(audioConfiguration))
.ConfigureServices(s => s
.AddWindowsSpeechServices()
.AddSingleton<IAudioConfigurationService>(audioConfiguration))
.Build();

public static IEnumerable<object[]> GetTestSamples()
Expand Down Expand Up @@ -220,3 +225,4 @@ internal void SetAudioInputToWaveStream(string waveFileName)
}
}
}
#endif
1 change: 1 addition & 0 deletions AdaptiveRemote.Speech.Tests/MSTestSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
28 changes: 20 additions & 8 deletions AdaptiveRemote.sln
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
# Visual Studio Version 18
VisualStudioVersion = 18.0.11217.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdaptiveRemote.App", "src\AdaptiveRemote.App\AdaptiveRemote.App.csproj", "{6C7C380B-D7A4-412E-8487-2AFC89EA802F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdaptiveRemote", "src\AdaptiveRemote\AdaptiveRemote.csproj", "{7BE31162-0D09-4F80-8CE5-978F7AECC1EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdaptiveRemote.Console", "src\AdaptiveRemote.Console\AdaptiveRemote.Console.csproj", "{345B73FC-07F9-490F-B566-2677D10B1834}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdaptiveRemote.Tests", "test\AdaptiveRemote.Tests\AdaptiveRemote.Tests.csproj", "{99181C45-EACC-45CE-87B3-20A4AA28E793}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdaptiveRemote.App.Tests", "test\AdaptiveRemote.App.Tests\AdaptiveRemote.App.Tests.csproj", "{99181C45-EACC-45CE-87B3-20A4AA28E793}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
CONTRIBUTING.md = CONTRIBUTING.md
Directory.Build.props = Directory.Build.props
README.md = README.md
Directory.Build.props = Directory.Build.Props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdaptiveRemote.Speech.Tests", "AdaptiveRemote.Speech.Tests\AdaptiveRemote.Speech.Tests.csproj", "{F00FC7B3-D7EA-4F1A-B8CE-9051E1611D96}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C7C380B-D7A4-412E-8487-2AFC89EA802F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C7C380B-D7A4-412E-8487-2AFC89EA802F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C7C380B-D7A4-412E-8487-2AFC89EA802F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C7C380B-D7A4-412E-8487-2AFC89EA802F}.Release|Any CPU.Build.0 = Release|Any CPU
{7BE31162-0D09-4F80-8CE5-978F7AECC1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7BE31162-0D09-4F80-8CE5-978F7AECC1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BE31162-0D09-4F80-8CE5-978F7AECC1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BE31162-0D09-4F80-8CE5-978F7AECC1EF}.Release|Any CPU.Build.0 = Release|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Release|Any CPU.Build.0 = Release|Any CPU
{345B73FC-07F9-490F-B566-2677D10B1834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{345B73FC-07F9-490F-B566-2677D10B1834}.Debug|Any CPU.Build.0 = Debug|Any CPU
{345B73FC-07F9-490F-B566-2677D10B1834}.Release|Any CPU.ActiveCfg = Release|Any CPU
{345B73FC-07F9-490F-B566-2677D10B1834}.Release|Any CPU.Build.0 = Release|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99181C45-EACC-45CE-87B3-20A4AA28E793}.Release|Any CPU.Build.0 = Release|Any CPU
{F00FC7B3-D7EA-4F1A-B8CE-9051E1611D96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F00FC7B3-D7EA-4F1A-B8CE-9051E1611D96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F00FC7B3-D7EA-4F1A-B8CE-9051E1611D96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F00FC7B3-D7EA-4F1A-B8CE-9051E1611D96}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
63 changes: 63 additions & 0 deletions src/AdaptiveRemote.App/AdaptiveRemote.App.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
Comment thread
jodavis marked this conversation as resolved.
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>$(MSBuildProjectName.Split('.')[0])</RootNamespace>
</PropertyGroup>

<ItemGroup>
Comment thread
jodavis marked this conversation as resolved.
Outdated
<Content Remove="compilerconfig.json" />
<Content Remove="wwwroot\css\app.less" />
</ItemGroup>

<ItemGroup>
<None Include="compilerconfig.json" />
<None Include="wwwroot\css\app.less" />
</ItemGroup>


<ItemGroup>
Comment thread
jodavis marked this conversation as resolved.
Outdated
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.2.0" />
<PackageReference Include="I8Beef.TiVo" Version="1.0.0.14" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.22" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
</ItemGroup>

<ItemGroup>
<Compile Update="Logging\LoggingMessages.Designer.cs">
<DependentUpon>LoggingMessages.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
</ItemGroup>

<ItemGroup>
<Content Update="wwwroot\css\app.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\css\app.min.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Logging\LoggingMessages.resx">
<LastGenOutput>LoggingMessages.Designer.cs</LastGenOutput>
<Generator>PublicResXFileCodeGenerator</Generator>
</EmbeddedResource>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AdaptiveRemote.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace AdaptiveRemote;
Expand All @@ -9,7 +8,6 @@ public static class AppHostBuilderExtensions
{
public static IHostBuilder ConfigureApp(this IHostBuilder hostBuilder)
=> hostBuilder
.AddBlazorUI()
.ConfigureTelemetry()
.AddRemoteServices()
.AddBroadlinkSupport()
Expand All @@ -30,13 +28,10 @@ public static IHostBuilder ConfigureAppSettings(this IHostBuilder hostBuilder, s
// to publish telemetry to.
// ["telemetry:Publish"] = "True"
});
config.AddUserSecrets<App>();
config.AddUserSecrets<UserSecretsKey>();
config.AddCommandLine(args);
});

private static IHostBuilder AddBlazorUI(this IHostBuilder hostBuilder)
{
return hostBuilder.ConfigureServices(services => services
.AddWpfBlazorWebView());
}
// This class is used to locate the user secrets assembly for this project.
private class UserSecretsKey { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ internal static IServiceCollection AddConversationServices(this IServiceCollecti
.AddScopedLifecycleService<ConversationController>()
.AddScoped<ISpeechRecognition, SpeechRecognition>()
.AddScoped<ISpeechSynthesis, SpeechSynthesis>()
.AddScoped<IGrammarProvider, StaticGrammarProvider>()
.AddScoped<ConversationStateMachine>()
.AddSingleton<ISpeechSynthesizer, SpeechSynthesizerWrapper>()
.AddSingleton<ISpeechRecognitionEngine, SpeechRecognitionEngineWrapper>()
.AddSingleton<IAudioConfigurationService, DefaultDeviceAudioConfiguration>()
.AddSingleton<IListeningController, ListeningController>()
.AddScoped(GetConversationViewModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ internal static IHostBuilder AddRemoteServices(this IHostBuilder builder)

internal static IServiceCollection AddRemoteServices(this IServiceCollection services)
=> services
.AddSingleton<IApplicationScopeFactory, BlazorWindowScopeFactory>()
.AddHostedService<ApplicationLifecycle>()
.AddScopedLifecycleService<LifecycleCommandService>()
.AddScoped<IRemoteDefinitionService, StaticCommandGroupProvider>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using AdaptiveRemote.Models;
using AdaptiveRemote.Utilities;
using Azure.Identity;
using Azure.Identity;
using Azure.Monitor.OpenTelemetry.Exporter;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down
13 changes: 13 additions & 0 deletions src/AdaptiveRemote.App/GlobalAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;

[assembly: InternalsVisibleTo("AdaptiveRemote.App.Tests")]
[assembly: InternalsVisibleTo("AdaptiveRemote.Speech.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

[assembly: NeutralResourcesLanguage("en-US")]

[assembly: SupportedOSPlatform("windows")]
Comment thread
jodavis marked this conversation as resolved.
Outdated
[assembly: SupportedOSPlatform("linux")]
11 changes: 11 additions & 0 deletions src/AdaptiveRemote.App/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Usage", "CA2254:Template should be a static expression",
Justification = "Error templates are coming from a resource file. They are static expressions, I'm just collecting them there.")]
[assembly: SuppressMessage("Performance", "CA1859:Use concrete types when possible for improved performance",
Justification = "Return types are cast to interfaces for future compatibility.")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AdaptiveRemote.Logging;

internal static class ILoggerExtensions
public static class ILoggerExtensions
{
private static readonly IReadOnlyDictionary<Message, string> LoggingMessages = InitializeLoggingMessages();

Expand Down Expand Up @@ -33,7 +33,7 @@ private static string ToMessageText(this Message message)

private static IReadOnlyDictionary<Message, string> InitializeLoggingMessages()
{
System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static;
System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static;
return Enum.GetValues<Message>()
.Select(x => (key: x, value: typeof(LoggingMessages).GetProperty(x.ToString(), flags)?.GetValue(null)))
.Where(x => x.value is not null)
Expand Down
Loading