Add SoundInstruction::SpeakNumberWith - #6
Conversation
…r ser/de, add new `SoundInstruction::SpeakNumberWith` variant.
There was a problem hiding this comment.
🟡 Changes recommended
The speak_number_with deserialization path contains a confirmed bug/mismatch in required-field handling (and should be aligned with NumberSpeakerConfig’s derived deserialization).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds serialization/deserialization support needed to introduce SoundInstruction::SpeakNumberWith, enabling callers to specify a NumberSpeakerConfig (voice file location/format and language) as part of the instruction JSON format.
Changes:
- Add
SoundInstruction::SpeakNumberWith(i64, NumberSpeakerConfig)with JSON (de)serialization and a round-trip test. - Introduce
NumberSpeakerConfig(serde-enabled) with defaults that depend on the active system language. - Implement
serde::Serialize/serde::DeserializeforLanguageTagand add basic serde tests.
File summaries
| File | Description |
|---|---|
| src/language.rs | Adds serde (de)serialization for LanguageTag plus tests. |
| src/audio/sound_instruction.rs | Adds SpeakNumberWith variant and JSON (de)serialization + test. |
| src/audio.rs | Introduces NumberSpeakerConfig (serde-enabled) and a deserialize test. |
| Cargo.toml | Enables serde derive feature. |
| Cargo.lock | Adds serde_derive dependency via serde derive feature. |
Review details
- Files reviewed: 4/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -89,6 +91,14 @@ pub enum SoundInstruction { | |||
| /// | |||
| /// Requires firmware version 260 or greater. | |||
| SpeakNumber(i64), | |||
There was a problem hiding this comment.
What about having SpeakNumber take an Option and make its json representation allow for an optional "config" field?
There was a problem hiding this comment.
I was avoiding needing to update uses of SpeakNumber in activities, which there are a few of. I could still do this though if you think it's preferable. We could change the json name from speak_number_with to speak_number and then check for if config is set, which would reduce the number of json instructions while keeping variants separate.
There was a problem hiding this comment.
I think most activities use the SoundBuilder which we should be able to adapt in a backwards compatible way.
There was a problem hiding this comment.
Oh and to be clear I am talking about the SpeakNumber SoundInstruction. Not the SpeakNumber struct used in native activities.
Adds
SoundInstruction::SpeakNumberWith, which allows us to pass aNumberSpeakerConfigto determine where to find voice files.