Skip to content

Commit

Permalink
Allow max length TimeSpans for config
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV committed Jan 30, 2024
1 parent 89600c1 commit 65eccc2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ButterSTT/Config/STTConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ public record STTConfig
[JsonPropertyName("hard_word_time_s")]
public double HardWordTimeS { get; set; } = 16.0;

// Converter utility properties
// Converter utilities
private static TimeSpan Seconds(double s) =>
s < 0d ? TimeSpan.MaxValue : TimeSpan.FromSeconds(s);

[JsonIgnore]
public IPEndPoint OSCEndpoint => IPEndPoint.Parse(OSCAddress);

[JsonIgnore]
public TimeSpan OSCChatboxRateLimit => TimeSpan.FromSeconds(OSCChatboxRateLimitS);
public TimeSpan OSCChatboxRateLimit => Seconds(OSCChatboxRateLimitS);

[JsonIgnore]
public TimeSpan WordTime => TimeSpan.FromSeconds(WordTimeS);
public TimeSpan WordTime => Seconds(WordTimeS);

[JsonIgnore]
public TimeSpan HardWordTime => TimeSpan.FromSeconds(HardWordTimeS);
public TimeSpan HardWordTime => Seconds(HardWordTimeS);
}

[JsonSerializable(typeof(STTConfig))]
Expand Down

0 comments on commit 65eccc2

Please sign in to comment.