Created
June 1, 2025 01:09
-
-
Save ChuckBaggett/fd70ef8b1f6e5dc86533b4d89f4e3350 to your computer and use it in GitHub Desktop.
file for jules
This file contains hidden or 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
using PiperSharp.Models; // For VoiceModel | |
using System; // For StringIsNullOrWhiteSpace, ToLowerInvariant, Split, ArgumentNullException | |
namespace TextToSpeechApp | |
{ | |
public class VoiceViewModel | |
{ | |
public VoiceModel Model { get; } | |
public string DisplayName { get; } | |
public VoiceViewModel(VoiceModel model) | |
{ | |
Model = model ?? throw new ArgumentNullException(nameof(model)); | |
string lang = model.Language?.Name ?? model.Language?.Code ?? "unk"; // Uses .Name | |
string keyDisplayName = model.Key ?? "unknown_key"; | |
string nameDisplayName = model.Name ?? ""; | |
DisplayName = $"{keyDisplayName} ({lang})"; | |
if (!string.IsNullOrWhiteSpace(nameDisplayName)) | |
{ | |
string keyPrefix = ""; | |
if (keyDisplayName.Contains("-")) | |
{ | |
keyPrefix = keyDisplayName.Split('-')[0]; | |
} | |
else | |
{ | |
keyPrefix = keyDisplayName; | |
} | |
bool nameIsKeyPrefix = nameDisplayName.ToLowerInvariant() == keyPrefix.ToLowerInvariant(); | |
bool nameIsFullKey = nameDisplayName.ToLowerInvariant() == keyDisplayName.ToLowerInvariant(); | |
if (!nameIsKeyPrefix && !nameIsFullKey) | |
{ | |
DisplayName = $"{nameDisplayName} - {keyDisplayName} ({lang})"; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment