From b12639a6184fb2bf0ccbe02b55211e613e57233c Mon Sep 17 00:00:00 2001 From: Spencer Grimes Date: Sat, 31 Jan 2026 16:46:24 -0600 Subject: [PATCH] fix: convert effect values to proper types when loading from preferences JSON stores numbers as strings, so pitch and speed were being returned as strings from get_user_effects(), causing format string errors like: 'Unknown format code d for object of type str' Now get_user_effects() explicitly converts: - pitch to int - speed to float This fixes the format string errors when logging or displaying effects. --- voice_manager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/voice_manager.py b/voice_manager.py index 259a241..438f2b6 100644 --- a/voice_manager.py +++ b/voice_manager.py @@ -195,12 +195,15 @@ class VoiceManager: # Effects management methods - def get_user_effects(self, user_id: int) -> dict[str, Any]: + def get_user_effects(self, user_id: int) -> dict[str, int | float]: """Get the audio effects for a user. Returns defaults if not set.""" effects = self._user_effects.get(user_id, {}) + # Convert to proper types (JSON stores them as strings) + pitch = effects.get("pitch", AudioEffects.PITCH_DEFAULT) + speed = effects.get("speed", AudioEffects.SPEED_DEFAULT) return { - "pitch": effects.get("pitch", AudioEffects.PITCH_DEFAULT), - "speed": effects.get("speed", AudioEffects.SPEED_DEFAULT), + "pitch": int(pitch) if pitch is not None else AudioEffects.PITCH_DEFAULT, + "speed": float(speed) if speed is not None else AudioEffects.SPEED_DEFAULT, } def set_user_effect(self, user_id: int, effect_name: str, value: Any) -> tuple[bool, str]: