Initialize volume from preferences on startup
Load initial volume from preferences and constrain it between 0.0 and 1.0. Set volume for music and TTS players based on initial volume.
This commit is contained in:
1 parent
76308cc209
commit
c91511c93e
1 file changed
+10
@@ -246,6 +246,11 @@ async def main() -> None:
|
|||||||
else:
|
else:
|
||||||
preferences = Preferences()
|
preferences = Preferences()
|
||||||
|
|
||||||
|
# Load volume from preferences on startup, and ensure it's between 0.0 and 1.0
|
||||||
|
initial_volume = preferences.volume if preferences.volume is not None else 1.0
|
||||||
|
initial_volume = max(0.0, min(1.0, float(initial_volume)))
|
||||||
|
preferences.volume = initial_volume
|
||||||
|
|
||||||
if args.enable_thinking_sound:
|
if args.enable_thinking_sound:
|
||||||
preferences.thinking_sound = 1
|
preferences.thinking_sound = 1
|
||||||
|
|
||||||
@@ -308,11 +313,16 @@ async def main() -> None:
|
|||||||
preferences_path=preferences_path,
|
preferences_path=preferences_path,
|
||||||
refractory_seconds=args.refractory_seconds,
|
refractory_seconds=args.refractory_seconds,
|
||||||
download_dir=args.download_dir,
|
download_dir=args.download_dir,
|
||||||
|
volume=initial_volume,
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.enable_thinking_sound:
|
if args.enable_thinking_sound:
|
||||||
state.save_preferences()
|
state.save_preferences()
|
||||||
|
|
||||||
|
initial_volume_percent = int(round(initial_volume * 100))
|
||||||
|
state.music_player.set_volume(initial_volume_percent)
|
||||||
|
state.tts_player.set_volume(initial_volume_percent)
|
||||||
|
|
||||||
process_audio_thread = threading.Thread(
|
process_audio_thread = threading.Thread(
|
||||||
target=process_audio,
|
target=process_audio,
|
||||||
args=(state, mic, args.audio_input_block_size),
|
args=(state, mic, args.audio_input_block_size),
|
||||||
|
|||||||
Reference in new issue
Block a user