-
-
Notifications
You must be signed in to change notification settings - Fork 83
RG-T117 More work with TTS #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ public static class TtsConfig | |
| public static string PiperModelDirectory = "/usr/local/share/piper-voices"; | ||
| public static string FfmpegExecutable = "ffmpeg"; | ||
| public static string TempDirectory = ""; | ||
| public static string CachePrefix = "tts"; | ||
| public static string CachePrefix = "tts2"; | ||
| public static int NormalizedSampleRate = 8000; | ||
| public static int NormalizedChannels = 1; | ||
| public static bool WarmupEnabled = true; | ||
|
|
@@ -73,8 +73,8 @@ public static class TtsConfig | |
| "Thank you. Your response has been recorded." | ||
| }); | ||
|
|
||
| public static int RateLimitPermitLimit = 60; | ||
| public static int RateLimitQueueLimit = 10; | ||
| public static int RateLimitPermitLimit = 600; | ||
| public static int RateLimitQueueLimit = 60; | ||
|
Comment on lines
+76
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Environment variable overrides in Web/Resgrid.Web.Tts/k8s/deployment.yaml silently negate the rate-limit increase, as ConfigProcessor.LoadAndProcessEnvVariables (Program.cs:17) loads these values into static TtsConfig fields that ApplyRateLimitOptions (ServiceCollectionExtensions.cs:77-78) passes to FixedWindowRateLimiter at Program.cs:86-87, causing futile retry-on-429 attempts. Update the RESGRID__TtsConfig__RateLimitPermitLimit and RESGRID__TtsConfig__RateLimitQueueLimit overrides at lines 35-36 to match the intended 600/60 code defaults. // Code defaults are correct; but deployment.yaml must be updated to match,
// otherwise the env override keeps production at 60/10:
// RESGRID__TtsConfig__RateLimitPermitLimit: "600"
// RESGRID__TtsConfig__RateLimitQueueLimit: "60"Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| public static int RateLimitWindowSeconds = 60; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,6 +304,9 @@ public async Task<bool> IsTestingEnabledForDepartmentAsync(int departmentId) | |
|
|
||
| public async Task<Coordinates> GetMapCenterCoordinatesAsync(Department department) | ||
| { | ||
| if (department == null) | ||
| return new Coordinates() { Latitude = 39.14086268299356, Longitude = -119.7583809782715 }; | ||
|
Comment on lines
+307
to
+308
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Magic number violation identified at line 308 and lines 371-372, where the default map center coordinates 39.14086268299356 and -119.7583809782715 are hardcoded as raw literals. Extract these fallback values into static readonly fields, following the existing cache key pattern at lines 17-25 to eliminate duplication across PersonnelController, UnitsController, MappingController v4, and LeafletMapView.tsx. Kody rule violation: Replace magic numbers with named constants private static readonly double DefaultLatitude = 39.14086268299356;
private static readonly double DefaultLongitude = -119.7583809782715;
// ...
if (department == null)
return new Coordinates() { Latitude = DefaultLatitude, Longitude = DefaultLongitude };Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
|
|
||
| var address = await GetBigBoardCenterAddressDepartmentAsync(department.DepartmentId); | ||
| var gpsCoordinates = await GetBigBoardCenterGpsCoordinatesDepartmentAsync(department.DepartmentId); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,11 @@ public sealed class AudioProcessingService : IAudioProcessingService | |
| private const float SpeedReferenceWpm = 175f; | ||
| private const float MinLengthScale = 0.25f; | ||
| private const float MaxLengthScale = 3.0f; | ||
| private const string DefaultEnglishModel = "en_US-norman-medium.onnx"; | ||
| private const string TelephoneAudioFilter = "highpass=f=200, lowpass=f=3000, anequalizer=c0 f=2500 w=1000 g=3 t=1"; | ||
| private const string DefaultEnglishModel = "en_US-ryan-high.onnx"; | ||
| // Lowpass sits at 3400 Hz (the telephony band edge) rather than 3000 so | ||
| // sibilants survive the mulaw encode; loudnorm keeps clips at a consistent | ||
| // perceived level over the phone. | ||
| private const string TelephoneAudioFilter = "highpass=f=200, lowpass=f=3400, anequalizer=c0 f=2500 w=1000 g=3 t=1, loudnorm=I=-16:TP=-1.5:LRA=11"; | ||
|
|
||
| /// <summary> | ||
| /// Maps eSpeak voice identifiers to Piper model filenames provisioned in the | ||
|
|
@@ -24,10 +27,10 @@ public sealed class AudioProcessingService : IAudioProcessingService | |
| private static readonly Dictionary<string, string> VoiceModelMap = new(StringComparer.OrdinalIgnoreCase) | ||
| { | ||
| // English variants | ||
| { "en", "en_US-norman-medium.onnx" }, | ||
| { "en-us", "en_US-norman-medium.onnx" }, | ||
| { "en-029", "en_US-norman-medium.onnx" }, | ||
| { "mb-us1", "en_US-norman-medium.onnx" }, | ||
| { "en", DefaultEnglishModel }, | ||
| { "en-us", DefaultEnglishModel }, | ||
| { "en-029", DefaultEnglishModel }, | ||
| { "mb-us1", DefaultEnglishModel }, | ||
|
|
||
| // Spanish | ||
| { "es", "es_MX-claude-high.onnx" }, | ||
|
|
@@ -202,8 +205,16 @@ private ProcessStartInfo CreatePiperStartInfo(string voice, int speed, string ou | |
| startInfo.ArgumentList.Add(outputFilePath); | ||
| startInfo.ArgumentList.Add("--length-scale"); | ||
| startInfo.ArgumentList.Add(invocation.LengthScale.ToString("0.00", CultureInfo.InvariantCulture)); | ||
| // 0.35s of silence between sentences — dispatch messages are strings of | ||
| // short sentences and need audible boundaries to stay intelligible. | ||
| startInfo.ArgumentList.Add("--sentence-silence"); | ||
| startInfo.ArgumentList.Add("0.0"); | ||
| startInfo.ArgumentList.Add("0.35"); | ||
| // Lower generation noise than the Piper defaults (0.667/0.8): reduces | ||
| // prosody jitter that makes digits and short words sound mumbled. | ||
| startInfo.ArgumentList.Add("--noise-scale"); | ||
| startInfo.ArgumentList.Add("0.333"); | ||
| startInfo.ArgumentList.Add("--noise-w"); | ||
| startInfo.ArgumentList.Add("0.4"); | ||
|
Comment on lines
+208
to
+217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Download Piper v1.2.0 binary and check its help output for argument names.
curl -fsSL "https://github.com/rhasspy/piper/releases/download/v1.2.0/piper_amd64.tar.gz" -o piper.tar.gz
tar -xzf piper.tar.gz
./piper/piper --help | grep -E 'sentence|noise'Repository: Resgrid/Core Length of output: 1266 Use Piper’s underscore flags here. 🤖 Prompt for AI Agents
Comment on lines
+208
to
+217
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates rule 'Replace magic numbers with named constants': the new piper synthesis parameters 0.35 (sentence silence), 0.333 (noise scale), and 0.4 (noise width) on lines 211, 215, 217 are meaningful numeric literals that should be extracted into named constants. The same class already extracts similar tuning values (SpeedReferenceWpm=175f, MinLengthScale=0.25f, MaxLengthScale=3.0f), establishing the expected pattern. // Named constants at the top of the class:
private const float SentenceSilence = 0.35f;
private const float NoiseScale = 0.333f;
private const float NoiseWidth = 0.4f;
// In CreatePiperStartInfo:
startInfo.ArgumentList.Add("--sentence-silence");
startInfo.ArgumentList.Add(SentenceSilence.ToString("0.00", CultureInfo.InvariantCulture));
startInfo.ArgumentList.Add("--noise-scale");
startInfo.ArgumentList.Add(NoiseScale.ToString("0.000", CultureInfo.InvariantCulture));
startInfo.ArgumentList.Add("--noise-w");
startInfo.ArgumentList.Add(NoiseWidth.ToString("0.0", CultureInfo.InvariantCulture));Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
|
|
||
| return startInfo; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHAT: The k8s deployment.yaml (line 28) sets
RESGRID__TtsConfig__CachePrefix: tts, which overrides the new code defaulttts2via the env-var → TtsConfig → TtsOptions chain in ServiceCollectionExtensions.cs:60, defeating the cache-busting intent in production. WHY: Non-English voice model names (Spanish, German, French, etc.) did not change in this PR, so their SHA256 cache hashes are identical to before; the prefix change fromtts→tts2was the only mechanism to invalidate their stale cache entries, but the env var override keeps it attts, causing non-English voices to serve old audio generated with sentence-silence 0.0, lowpass 3000, and no loudnorm/noise parameters indefinitely. HOW: Update the k8s deployment.yamlRESGRID__TtsConfig__CachePrefixvalue fromttstotts2to match the code default, or remove the env var override so the code default takes effect.Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.