Skip to content

Commit

Permalink
Merge pull request #8 from tsubakimoto/issue5
Browse files Browse the repository at this point in the history
検出言語・翻訳言語を選べるようにする
  • Loading branch information
tsubakimoto authored Nov 27, 2023
2 parents 98ec3b4 + 2f671aa commit f0ce91f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 18 additions & 2 deletions src/SpeechTranslatorConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
Settings? settings = config.GetRequiredSection(nameof(Settings)).Get<Settings>();
var region = settings?.Region ?? throw new ArgumentNullException("region");
var subscriptionKey = settings?.SubscriptionKey ?? throw new ArgumentNullException("subscriptionKey");
var fromLanguage = settings?.FromLanguage ?? throw new ArgumentNullException("fromLanguage");
var targetLanguage = settings?.TargetLanguage ?? throw new ArgumentNullException("targetLanguage");
var fromLanguage = DetermineLanguage("speaker") ?? throw new ArgumentNullException("fromLanguage");
Console.WriteLine();
var targetLanguage = DetermineLanguage("translator") ?? throw new ArgumentNullException("targetLanguage");
Console.WriteLine();

Console.Write("Record file name: ");
var filePath = Console.ReadLine() ?? throw new ArgumentNullException("filePath");
Expand Down Expand Up @@ -51,6 +53,20 @@
Console.WriteLine("Executing finally block.");
}

static string? DetermineLanguage(string title)
{
Console.WriteLine("1. English (en-US)");
Console.WriteLine("2. Japanese (ja-JP)");
Console.Write($"Select {title} language: ");

return Console.ReadLine() switch
{
"1" => "en-US",
"2" => "ja-JP",
_ => null
};
}

static async Task MultiLingualTranslation(string filepath, SpeechTranslationConfig config)
{
var autoDetectSourceLanguageConfig = AutoDetectSourceLanguageConfig.FromLanguages(new string[] { config.SpeechRecognitionLanguage });
Expand Down
4 changes: 1 addition & 3 deletions src/SpeechTranslatorConsole/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"Settings": {
"Region": "YOUR_REGION",
"SubscriptionKey": "YOUR_SUBSCRIPTION_KEY",
"FromLanguage": "en-US",
"TargetLanguage": "ja"
"SubscriptionKey": "YOUR_SUBSCRIPTION_KEY"
}
}

0 comments on commit f0ce91f

Please sign in to comment.