Skip to content

Add SoundInstruction::SpeakNumberWith - #6

Open
benjhar wants to merge 2 commits into
mainfrom
feat_number_speaker
Open

Add SoundInstruction::SpeakNumberWith#6
benjhar wants to merge 2 commits into
mainfrom
feat_number_speaker

Conversation

@benjhar

@benjhar benjhar commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds SoundInstruction::SpeakNumberWith, which allows us to pass a NumberSpeakerConfig to determine where to find voice files.

…r ser/de, add new `SoundInstruction::SpeakNumberWith` variant.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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::Deserialize for LanguageTag and 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.

Comment thread src/audio/sound_instruction.rs Outdated
Comment thread src/audio.rs Outdated
@benjhar
benjhar requested a review from benhansen-io September 4, 2026 14:06
@@ -89,6 +91,14 @@ pub enum SoundInstruction {
///
/// Requires firmware version 260 or greater.
SpeakNumber(i64),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about having SpeakNumber take an Option and make its json representation allow for an optional "config" field?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most activities use the SoundBuilder which we should be able to adapt in a backwards compatible way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and to be clear I am talking about the SpeakNumber SoundInstruction. Not the SpeakNumber struct used in native activities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants