diff --git a/Translator/Translator/MainWindow.xaml.cs b/Translator/Translator/MainWindow.xaml.cs index a1629e4..1feb819 100644 --- a/Translator/Translator/MainWindow.xaml.cs +++ b/Translator/Translator/MainWindow.xaml.cs @@ -16,6 +16,8 @@ public sealed partial class MainWindow : Window private static readonly string AZURE_LANGUAGE_RESOURCE_FILE_PATH = $"{AppDomain.CurrentDomain.BaseDirectory}PrebuiltNeuralVoicesAzureSpeech.json"; + private static readonly string SPEECH_SERVICE_REGIONS_FILE_PATH = $"{AppDomain.CurrentDomain.BaseDirectory}SpeechServiceRegions.json"; + #endregion Private fields public MainWindow() @@ -36,9 +38,16 @@ public MainWindow() private void Initialize() { - var streamReader = new StreamReader(AZURE_LANGUAGE_RESOURCE_FILE_PATH); - var jsonString = streamReader.ReadToEnd(); - var prebuiltNeuralVoices = JsonConvert.DeserializeObject>(jsonString).DistinctBy(v => v.Locale); + var speechServiceRegionsStreamReader = new StreamReader(SPEECH_SERVICE_REGIONS_FILE_PATH); + var speechServiceRegionsJsonString = speechServiceRegionsStreamReader.ReadToEnd(); + var speechServiceRegions = JsonConvert.DeserializeObject>(speechServiceRegionsJsonString); + + (App.Current.Services.GetService(typeof(SettingsPageViewModel)) as SettingsPageViewModel).SpeechServiceRegions = speechServiceRegions; + + var azureLanguageResourceStreamReader = new StreamReader(AZURE_LANGUAGE_RESOURCE_FILE_PATH); + var azureLanguageResourceJsonString = azureLanguageResourceStreamReader.ReadToEnd(); + var prebuiltNeuralVoices = JsonConvert.DeserializeObject>(azureLanguageResourceJsonString).DistinctBy(v => v.Locale); + Navigate(typeof(HomePage), prebuiltNeuralVoices); } diff --git a/Translator/Translator/Models/Account.cs b/Translator/Translator/Models/Account.cs index fe565fe..d1776e3 100644 --- a/Translator/Translator/Models/Account.cs +++ b/Translator/Translator/Models/Account.cs @@ -11,5 +11,8 @@ public class Account [DataMember(Name = "apiKey")] public string ApiKey { get; set; } + + [DataMember(Name = "region")] + public string Region { get; set; } } } \ No newline at end of file diff --git a/Translator/Translator/Models/SpeechServiceRegion.cs b/Translator/Translator/Models/SpeechServiceRegion.cs new file mode 100644 index 0000000..f7f2f51 --- /dev/null +++ b/Translator/Translator/Models/SpeechServiceRegion.cs @@ -0,0 +1,14 @@ +using System.Runtime.Serialization; + +namespace Translator.Models +{ + [DataContract] + public class SpeechServiceRegion + { + [DataMember(Name = "id")] + public string Id { get; set; } + + [DataMember(Name = "name")] + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Translator/Translator/SpeechServiceRegions.json b/Translator/Translator/SpeechServiceRegions.json new file mode 100644 index 0000000..f1efb4a --- /dev/null +++ b/Translator/Translator/SpeechServiceRegions.json @@ -0,0 +1,122 @@ +[ + { + "id": "australiaeast", + "name": "Australia East" + }, + { + "id": "brazilsouth", + "name": "Brazil South" + }, + { + "id": "canadacentral", + "name": "Canada Central" + }, + { + "id": "centralindia", + "name": "Central India" + }, + { + "id": "centralus", + "name": "Central US" + }, + { + "id": "eastasia", + "name": "East Asia" + }, + { + "id": "eastus", + "name": "East US" + }, + { + "id": "eastus2", + "name": "East US 2" + }, + { + "id": "francecentral", + "name": "France Central" + }, + { + "id": "germanywestcentral", + "name": "Germany West Central" + }, + { + "id": "japaneast", + "name": "Japan East" + }, + { + "id": "japanwest", + "name": "Japan West" + }, + { + "id": "koreacentral", + "name": "Korea Central" + }, + { + "id": "northcentralus", + "name": "North Central US" + }, + { + "id": "northeurope", + "name": "North Europe" + }, + { + "id": "norwayeast", + "name": "Norway East" + }, + { + "id": "qatarcentral", + "name": "Qatar Central" + }, + { + "id": "southafricanorth", + "name": "South Africa North" + }, + { + "id": "southcentralus", + "name": "South Central US" + }, + { + "id": "southeastasia", + "name": "Southeast Asia" + }, + { + "id": "swedencentral", + "name": "Sweden Central" + }, + { + "id": "switzerlandnorth", + "name": "Switzerland North" + }, + { + "id": "switzerlandwest", + "name": "Switzerland West" + }, + { + "id": "uaenorth", + "name": "UAE North" + }, + { + "id": "uksouth", + "name": "UK South" + }, + { + "id": "westcentralus", + "name": "West Central US" + }, + { + "id": "westeurope", + "name": "West Europe" + }, + { + "id": "westus", + "name": "West US" + }, + { + "id": "westus2", + "name": "West US 2" + }, + { + "id": "westus3", + "name": "West US 3" + } +] \ No newline at end of file diff --git a/Translator/Translator/Strings/en-US/Resources.resw b/Translator/Translator/Strings/en-US/Resources.resw index 26ac410..464f629 100644 --- a/Translator/Translator/Strings/en-US/Resources.resw +++ b/Translator/Translator/Strings/en-US/Resources.resw @@ -162,4 +162,7 @@ Settings + + Region + \ No newline at end of file diff --git a/Translator/Translator/Strings/fr-FR/Resources.resw b/Translator/Translator/Strings/fr-FR/Resources.resw index 7a71fd3..0efd14a 100644 --- a/Translator/Translator/Strings/fr-FR/Resources.resw +++ b/Translator/Translator/Strings/fr-FR/Resources.resw @@ -162,4 +162,7 @@ Paramètres + + Région + \ No newline at end of file diff --git a/Translator/Translator/Translator.csproj b/Translator/Translator/Translator.csproj index eb0da7c..7dbe7ef 100644 --- a/Translator/Translator/Translator.csproj +++ b/Translator/Translator/Translator.csproj @@ -31,6 +31,9 @@ PreserveNewest + + PreserveNewest + MSBuild:Compile diff --git a/Translator/Translator/Views/SettingsPage.xaml b/Translator/Translator/Views/SettingsPage.xaml index 05ed851..078ebe0 100644 --- a/Translator/Translator/Views/SettingsPage.xaml +++ b/Translator/Translator/Views/SettingsPage.xaml @@ -142,16 +142,25 @@ + + +