-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
167 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<UserSecretsId>716f7a77-339c-46aa-89a6-2dc47eab1d23</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\My1kWordsEe\My1kWordsEe.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
using My1kWordsEe.Services; | ||
using My1kWordsEe.Services.Cqs; | ||
using My1kWordsEe.Services.Db; | ||
|
||
namespace ConsoleApp | ||
{ | ||
internal class Program | ||
{ | ||
|
||
private static readonly string[] Words = new string[] | ||
{ | ||
}; | ||
|
||
static async Task Main(string[] args) | ||
{ | ||
using ILoggerFactory factory = LoggerFactory.Create(builder => builder.AddConsole()); | ||
IConfigurationRoot config = new ConfigurationBuilder() | ||
.AddUserSecrets<Program>() | ||
.Build(); | ||
|
||
var openAiKey = config["Secrets:OpenAiKey"]; | ||
|
||
if (string.IsNullOrWhiteSpace(openAiKey)) | ||
{ | ||
throw new ApplicationException("Secrets:OpenAiKey is missing"); | ||
} | ||
|
||
var azureBlobConnectionString = config["Secrets:AzureBlobConnectionString"]; | ||
|
||
if (string.IsNullOrWhiteSpace(azureBlobConnectionString)) | ||
{ | ||
throw new ApplicationException("Secrets:AzureBlobConnectionString is missing"); | ||
} | ||
|
||
var blob = new AzureBlobService(azureBlobConnectionString); | ||
var openAi = new OpenAiService(factory.CreateLogger<OpenAiService>(), openAiKey); | ||
var ensure = new EnsureWordCommand(blob, openAi); | ||
|
||
var errors = new List<string>(); | ||
|
||
Console.WriteLine(Words.Length); | ||
foreach (var word in Words) | ||
{ | ||
Console.WriteLine($"Processing {word}"); | ||
|
||
var ensureCmd = await ensure.Invoke(word); | ||
if (ensureCmd.IsFailure) | ||
{ | ||
Console.WriteLine($"Failed to ensure {word}: {ensureCmd.Error}"); | ||
errors.Add($"Failed to ensure {word}: {ensureCmd.Error}"); | ||
} | ||
|
||
var data = await blob.GetWordData(word); | ||
|
||
if (data.IsSuccess) | ||
{ | ||
var wordData = data.Value; | ||
var update = wordData with | ||
{ | ||
EeAudioUrl = new Uri( | ||
$"https://my1kee.blob.core.windows.net/audio/{wordData.EeWord}.wav") | ||
}; | ||
|
||
await blob.SaveWordData(update); | ||
} | ||
else | ||
{ | ||
errors.Add($"Failed to get data for {word}"); | ||
Console.WriteLine($"Failed to get data for {word}"); | ||
} | ||
} | ||
|
||
File.WriteAllLines("cmd-errors-5.txt", errors); | ||
} | ||
} | ||
} |
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
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
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
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
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
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