Skip to content

Commit 2f28567

Browse files
Merge pull request #142 from nullinside-development-group/feat/voices
feat: updating code to see all voices installed on system
2 parents 2b2603d + 782d5b6 commit 2f28567

File tree

10 files changed

+74
-10
lines changed

10 files changed

+74
-10
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install .NET Core
3737
uses: actions/setup-dotnet@v3
3838
with:
39-
dotnet-version: 9.x.x
39+
dotnet-version: 10.x.x
4040

4141
# Execute the build
4242
- name: Execute Release Build
@@ -58,7 +58,7 @@ jobs:
5858
- name: Install .NET Core
5959
uses: actions/setup-dotnet@v3
6060
with:
61-
dotnet-version: 9.x.x
61+
dotnet-version: 10.x.x
6262

6363
# Execute the tests
6464
- name: Execute Tests
@@ -120,7 +120,7 @@ jobs:
120120
- name: Install .NET Core
121121
uses: actions/setup-dotnet@v3
122122
with:
123-
dotnet-version: 9.x.x
123+
dotnet-version: 10.x.x
124124

125125
# Execute the build
126126
- name: Execute Build

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
22
USER $APP_UID
33
WORKDIR /app
44

5-
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
5+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
66
ARG BUILD_CONFIGURATION=Release
77
ARG TAG_VERSION
88
WORKDIR /src

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
Tools to aid twitch streamers.
44

5+
## To Install Additional Voices
6+
7+
To install additional voices you need to install the language in Windows 11:
8+
1. Open the start menu and search for `Language Settings`
9+
10+
![The language settings menu](assets/images/language-settings.png)
11+
12+
2. In the "Preferred languages" row, click "Add a language"
13+
14+
![Add a language button](assets/images/add-a-language.png)
15+
16+
3. In the "Choose a language to install" dialog, select the language with "Text-to-speech" icon.
17+
* **Note:** Only items with the text-to-speech icon will show up in the application once installed.
18+
19+
![Choose language dialog](assets/images/choose-language.png)
20+
21+
4. In the "Install language features" dialog, you only need to install the "Text-to-speech" for the language and click install.
22+
* **Note:** All other boxes may be **unchecked**.
23+
24+
![Install language features dialog](assets/images/install-language-features.png)
25+
26+
Once installed (it may take some time), restart the application and they should be displayed in the settings menu under
27+
TTS Voices.
28+
29+
![TTS settings](assets/images/tts-voices.png)
30+
531
## Design
632

733
### Account Management

assets/images/add-a-language.png

4.42 KB
Loading

assets/images/choose-language.png

46.4 KB
Loading
52 KB
Loading
19.9 KB
Loading

assets/images/tts-voices.png

84.8 KB
Loading

src/Nullinside.TwitchStreamingTools/Nullinside.TwitchStreamingTools.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
@@ -64,11 +64,11 @@
6464
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
6565
<PackageReference Include="DynamicData" Version="9.4.1"/>
6666
<PackageReference Include="log4net" Version="3.2.0"/>
67-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.10" />
67+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
6868
<PackageReference Include="NAudio.Wasapi" Version="2.2.1"/>
6969
<PackageReference Include="NAudio.WinMM" Version="2.2.1"/>
7070
<PackageReference Include="PInvoke.User32" Version="0.7.124"/>
71-
<PackageReference Include="System.Speech" Version="9.0.10" />
71+
<PackageReference Include="System.Speech" Version="10.0.0" />
7272
</ItemGroup>
7373

7474
<ItemGroup>

src/Nullinside.TwitchStreamingTools/ViewModels/Pages/SettingsView/SettingsViewModel.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ public SettingsViewModel(IConfiguration configuration, TtsPhoneticWordsViewModel
164164

165165
// Get the list of TTS voices and set the default to either what we have in the configuration or the system
166166
// default whichever is more appropriate.
167-
using var speech = new SpeechSynthesizer();
168-
_ttsVoices = new ObservableCollection<string>(speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name));
167+
_ttsVoices = new ObservableCollection<string>(GetFilteredTtsVoices());
169168
_selectedTtsVoice = Configuration.GetDefaultTtsVoice();
170169

171170
// Get the volume and set the default to either what we have in the configuration or to half-volume. Why half-volume?
@@ -364,6 +363,45 @@ public bool SayUsernameWithMessage {
364363
}
365364
}
366365

366+
/// <summary>
367+
/// Gets the filtered list of voices, removing duplicates.
368+
/// </summary>
369+
/// <returns>The list of voice names.</returns>
370+
private IEnumerable<string> GetFilteredTtsVoices() {
371+
const string duplicatePostfix = " Desktop";
372+
using var speech = new SpeechSynthesizer();
373+
IEnumerable<string> allVoices = speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name);
374+
var unique = new HashSet<string>();
375+
foreach (string voice in allVoices) {
376+
// If the voice ends in the " Desktop" it means there could be a duplicate voice without that on the end
377+
// e.g:
378+
// Microsoft David Desktop
379+
// vs
380+
// Microsoft David
381+
//
382+
// These both point to the same thing and we only need one of them. The tricky part is we can't be sure which one
383+
// we will encounter so we have to check if the other exists and make sure only one of the two end up in the list.
384+
if (voice.EndsWith(duplicatePostfix)) {
385+
// If a " Desktop" voice has a voice without it in the list already, then don't add it. Skip this one.
386+
if (unique.Contains(voice.Substring(0, voice.Length - duplicatePostfix.Length))) {
387+
continue;
388+
}
389+
}
390+
else {
391+
// If it's not a desktop voice, check if this voice has another voice already with the " Desktop" on the end.
392+
// If we find it, remove it and add this one instead.
393+
if (unique.Contains(voice + duplicatePostfix)) {
394+
unique.Remove(voice + duplicatePostfix);
395+
}
396+
}
397+
398+
unique.Add(voice);
399+
}
400+
401+
// Sort them to be nice.
402+
return unique.OrderByDescending(s => s);
403+
}
404+
367405
/// <summary>
368406
/// Handles updating the configuration when the skip TTS keybind changes.
369407
/// </summary>

0 commit comments

Comments
 (0)