Try to keep speech form stuttering with status keys.
This commit is contained in:
parent
c242fc6832
commit
943e2acf53
16
__init__.py
16
__init__.py
@ -53,6 +53,10 @@ bgmVolume = 0.75 # Default background music volume
|
|||||||
sfxVolume = 1.0 # Default sound effects volume
|
sfxVolume = 1.0 # Default sound effects volume
|
||||||
masterVolume = 1.0 # Default master volume
|
masterVolume = 1.0 # Default master volume
|
||||||
|
|
||||||
|
# Handle speech delays so we don't get stuttering
|
||||||
|
_lastSpoken = {"text": None, "time": 0}
|
||||||
|
_speechDelay = 250 # ms
|
||||||
|
|
||||||
class Scoreboard:
|
class Scoreboard:
|
||||||
"""Handles high score tracking with player names."""
|
"""Handles high score tracking with player names."""
|
||||||
|
|
||||||
@ -337,6 +341,18 @@ def speak(text, interrupt=True):
|
|||||||
text (str): Text to speak and display
|
text (str): Text to speak and display
|
||||||
interrupt (bool): Whether to interrupt current speech (default: True)
|
interrupt (bool): Whether to interrupt current speech (default: True)
|
||||||
"""
|
"""
|
||||||
|
current_time = pygame.time.get_ticks()
|
||||||
|
|
||||||
|
# Check if this is the same text within the delay window
|
||||||
|
if (_lastSpoken["text"] == text and
|
||||||
|
current_time - _lastSpoken["time"] < _speechDelay):
|
||||||
|
return
|
||||||
|
|
||||||
|
# Update last spoken tracking
|
||||||
|
_lastSpoken["text"] = text
|
||||||
|
_lastSpoken["time"] = current_time
|
||||||
|
|
||||||
|
# Proceed with speech
|
||||||
if speechProvider == "speechd":
|
if speechProvider == "speechd":
|
||||||
if interrupt:
|
if interrupt:
|
||||||
spd.cancel()
|
spd.cancel()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user