Fix display user not updating locally until app restart
Engines now read user.name from the config object at transcription time instead of caching it at init, so name changes take effect immediately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -58,8 +58,8 @@ class RealtimeTranscriptionEngine:
|
||||
no_log_file: bool = True,
|
||||
# Audio device
|
||||
input_device_index: Optional[int] = None,
|
||||
# User name
|
||||
user_name: str = ""
|
||||
# App config (for reading user.name at transcription time)
|
||||
app_config=None
|
||||
):
|
||||
"""
|
||||
Initialize RealtimeSTT transcription engine.
|
||||
@@ -82,7 +82,7 @@ class RealtimeTranscriptionEngine:
|
||||
initial_prompt: Optional prompt to guide transcription
|
||||
no_log_file: Disable RealtimeSTT logging
|
||||
input_device_index: Audio input device index
|
||||
user_name: User name for transcriptions
|
||||
app_config: App Config object for reading user.name dynamically
|
||||
"""
|
||||
self.model = model
|
||||
self.language = language
|
||||
@@ -100,7 +100,7 @@ class RealtimeTranscriptionEngine:
|
||||
self.enable_realtime = enable_realtime_transcription
|
||||
self.realtime_model = realtime_model
|
||||
self.realtime_processing_pause = realtime_processing_pause
|
||||
self.user_name = user_name
|
||||
self.app_config = app_config
|
||||
|
||||
# Callbacks
|
||||
self.realtime_callback: Optional[Callable[[TranscriptionResult], None]] = None
|
||||
@@ -162,6 +162,11 @@ class RealtimeTranscriptionEngine:
|
||||
self.realtime_callback = realtime_callback
|
||||
self.final_callback = final_callback
|
||||
|
||||
def _get_user_name(self) -> str:
|
||||
if self.app_config:
|
||||
return self.app_config.get('user.name', '')
|
||||
return ''
|
||||
|
||||
def _on_realtime_transcription(self, text: str):
|
||||
"""Internal callback for realtime transcriptions."""
|
||||
if self.realtime_callback and text.strip():
|
||||
@@ -169,7 +174,7 @@ class RealtimeTranscriptionEngine:
|
||||
text=text,
|
||||
is_final=False,
|
||||
timestamp=datetime.now(),
|
||||
user_name=self.user_name
|
||||
user_name=self._get_user_name()
|
||||
)
|
||||
self.realtime_callback(result)
|
||||
|
||||
@@ -180,7 +185,7 @@ class RealtimeTranscriptionEngine:
|
||||
text=text,
|
||||
is_final=True,
|
||||
timestamp=datetime.now(),
|
||||
user_name=self.user_name
|
||||
user_name=self._get_user_name()
|
||||
)
|
||||
self.final_callback(result)
|
||||
|
||||
@@ -406,10 +411,6 @@ class RealtimeTranscriptionEngine:
|
||||
if self.is_recording:
|
||||
print("VAD settings updated. Restart transcription to apply changes.")
|
||||
|
||||
def set_user_name(self, user_name: str):
|
||||
"""Set the user name for transcriptions."""
|
||||
self.user_name = user_name
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"RealtimeTranscriptionEngine(model={self.model}, device={self.device}, running={self.is_recording})"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user