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:
@@ -276,7 +276,6 @@ class AppController:
|
|||||||
self.current_model_size = model
|
self.current_model_size = model
|
||||||
self.current_device_config = device_config
|
self.current_device_config = device_config
|
||||||
|
|
||||||
user_name = self.config.get('user.name', 'User')
|
|
||||||
continuous_mode = self.config.get('transcription.continuous_mode', False)
|
continuous_mode = self.config.get('transcription.continuous_mode', False)
|
||||||
|
|
||||||
if continuous_mode:
|
if continuous_mode:
|
||||||
@@ -293,7 +292,6 @@ class AppController:
|
|||||||
if remote_mode in ('managed', 'byok'):
|
if remote_mode in ('managed', 'byok'):
|
||||||
self.transcription_engine = DeepgramTranscriptionEngine(
|
self.transcription_engine = DeepgramTranscriptionEngine(
|
||||||
config=self.config,
|
config=self.config,
|
||||||
user_name=user_name,
|
|
||||||
input_device_index=audio_device,
|
input_device_index=audio_device,
|
||||||
)
|
)
|
||||||
self.transcription_engine.set_callbacks(
|
self.transcription_engine.set_callbacks(
|
||||||
@@ -343,7 +341,7 @@ class AppController:
|
|||||||
initial_prompt=self.config.get('transcription.initial_prompt', ''),
|
initial_prompt=self.config.get('transcription.initial_prompt', ''),
|
||||||
no_log_file=self.config.get('transcription.no_log_file', True),
|
no_log_file=self.config.get('transcription.no_log_file', True),
|
||||||
input_device_index=audio_device,
|
input_device_index=audio_device,
|
||||||
user_name=user_name,
|
app_config=self.config,
|
||||||
)
|
)
|
||||||
self.transcription_engine.set_callbacks(
|
self.transcription_engine.set_callbacks(
|
||||||
realtime_callback=self._on_realtime_transcription,
|
realtime_callback=self._on_realtime_transcription,
|
||||||
|
|||||||
@@ -36,18 +36,16 @@ class DeepgramTranscriptionEngine:
|
|||||||
# Construction / configuration
|
# Construction / configuration
|
||||||
# ------------------------------------------------------------------ #
|
# ------------------------------------------------------------------ #
|
||||||
|
|
||||||
def __init__(self, config, user_name: str = "User", input_device_index: Optional[int] = None):
|
def __init__(self, config, input_device_index: Optional[int] = None):
|
||||||
"""
|
"""
|
||||||
Initialise the engine from a :class:`client.config.Config` object.
|
Initialise the engine from a :class:`client.config.Config` object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
config: Application ``Config`` instance.
|
config: Application ``Config`` instance.
|
||||||
user_name: Display name attached to transcriptions.
|
|
||||||
input_device_index: Index of the audio input device to use
|
input_device_index: Index of the audio input device to use
|
||||||
(``None`` for the system default).
|
(``None`` for the system default).
|
||||||
"""
|
"""
|
||||||
self.config = config
|
self.config = config
|
||||||
self.user_name = user_name
|
|
||||||
self.input_device_index = input_device_index
|
self.input_device_index = input_device_index
|
||||||
|
|
||||||
# Mode: 'managed' (proxy) or 'byok' (direct Deepgram)
|
# Mode: 'managed' (proxy) or 'byok' (direct Deepgram)
|
||||||
@@ -454,7 +452,7 @@ class DeepgramTranscriptionEngine:
|
|||||||
text=text,
|
text=text,
|
||||||
is_final=is_final,
|
is_final=is_final,
|
||||||
timestamp=datetime.now(),
|
timestamp=datetime.now(),
|
||||||
user_name=self.user_name,
|
user_name=self.config.get('user.name', 'User'),
|
||||||
)
|
)
|
||||||
if is_final:
|
if is_final:
|
||||||
if self.final_callback:
|
if self.final_callback:
|
||||||
@@ -505,7 +503,7 @@ class DeepgramTranscriptionEngine:
|
|||||||
text=transcript,
|
text=transcript,
|
||||||
is_final=is_final,
|
is_final=is_final,
|
||||||
timestamp=datetime.now(),
|
timestamp=datetime.now(),
|
||||||
user_name=self.user_name,
|
user_name=self.config.get('user.name', 'User'),
|
||||||
)
|
)
|
||||||
if is_final:
|
if is_final:
|
||||||
if self.final_callback:
|
if self.final_callback:
|
||||||
@@ -536,10 +534,6 @@ class DeepgramTranscriptionEngine:
|
|||||||
pass
|
pass
|
||||||
self._ws = None
|
self._ws = None
|
||||||
|
|
||||||
def set_user_name(self, user_name: str):
|
|
||||||
"""Update the user name attached to future transcriptions."""
|
|
||||||
self.user_name = user_name
|
|
||||||
|
|
||||||
def is_recording_active(self) -> bool:
|
def is_recording_active(self) -> bool:
|
||||||
"""Return ``True`` if audio is currently being captured."""
|
"""Return ``True`` if audio is currently being captured."""
|
||||||
return self._is_recording
|
return self._is_recording
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ class RealtimeTranscriptionEngine:
|
|||||||
no_log_file: bool = True,
|
no_log_file: bool = True,
|
||||||
# Audio device
|
# Audio device
|
||||||
input_device_index: Optional[int] = None,
|
input_device_index: Optional[int] = None,
|
||||||
# User name
|
# App config (for reading user.name at transcription time)
|
||||||
user_name: str = ""
|
app_config=None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Initialize RealtimeSTT transcription engine.
|
Initialize RealtimeSTT transcription engine.
|
||||||
@@ -82,7 +82,7 @@ class RealtimeTranscriptionEngine:
|
|||||||
initial_prompt: Optional prompt to guide transcription
|
initial_prompt: Optional prompt to guide transcription
|
||||||
no_log_file: Disable RealtimeSTT logging
|
no_log_file: Disable RealtimeSTT logging
|
||||||
input_device_index: Audio input device index
|
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.model = model
|
||||||
self.language = language
|
self.language = language
|
||||||
@@ -100,7 +100,7 @@ class RealtimeTranscriptionEngine:
|
|||||||
self.enable_realtime = enable_realtime_transcription
|
self.enable_realtime = enable_realtime_transcription
|
||||||
self.realtime_model = realtime_model
|
self.realtime_model = realtime_model
|
||||||
self.realtime_processing_pause = realtime_processing_pause
|
self.realtime_processing_pause = realtime_processing_pause
|
||||||
self.user_name = user_name
|
self.app_config = app_config
|
||||||
|
|
||||||
# Callbacks
|
# Callbacks
|
||||||
self.realtime_callback: Optional[Callable[[TranscriptionResult], None]] = None
|
self.realtime_callback: Optional[Callable[[TranscriptionResult], None]] = None
|
||||||
@@ -162,6 +162,11 @@ class RealtimeTranscriptionEngine:
|
|||||||
self.realtime_callback = realtime_callback
|
self.realtime_callback = realtime_callback
|
||||||
self.final_callback = final_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):
|
def _on_realtime_transcription(self, text: str):
|
||||||
"""Internal callback for realtime transcriptions."""
|
"""Internal callback for realtime transcriptions."""
|
||||||
if self.realtime_callback and text.strip():
|
if self.realtime_callback and text.strip():
|
||||||
@@ -169,7 +174,7 @@ class RealtimeTranscriptionEngine:
|
|||||||
text=text,
|
text=text,
|
||||||
is_final=False,
|
is_final=False,
|
||||||
timestamp=datetime.now(),
|
timestamp=datetime.now(),
|
||||||
user_name=self.user_name
|
user_name=self._get_user_name()
|
||||||
)
|
)
|
||||||
self.realtime_callback(result)
|
self.realtime_callback(result)
|
||||||
|
|
||||||
@@ -180,7 +185,7 @@ class RealtimeTranscriptionEngine:
|
|||||||
text=text,
|
text=text,
|
||||||
is_final=True,
|
is_final=True,
|
||||||
timestamp=datetime.now(),
|
timestamp=datetime.now(),
|
||||||
user_name=self.user_name
|
user_name=self._get_user_name()
|
||||||
)
|
)
|
||||||
self.final_callback(result)
|
self.final_callback(result)
|
||||||
|
|
||||||
@@ -406,10 +411,6 @@ class RealtimeTranscriptionEngine:
|
|||||||
if self.is_recording:
|
if self.is_recording:
|
||||||
print("VAD settings updated. Restart transcription to apply changes.")
|
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:
|
def __repr__(self) -> str:
|
||||||
return f"RealtimeTranscriptionEngine(model={self.model}, device={self.device}, running={self.is_recording})"
|
return f"RealtimeTranscriptionEngine(model={self.model}, device={self.device}, running={self.is_recording})"
|
||||||
|
|
||||||
|
|||||||
@@ -401,7 +401,6 @@ class MainWindow(QMainWindow):
|
|||||||
# Use Deepgram-based remote transcription
|
# Use Deepgram-based remote transcription
|
||||||
self.transcription_engine = DeepgramTranscriptionEngine(
|
self.transcription_engine = DeepgramTranscriptionEngine(
|
||||||
config=self.config,
|
config=self.config,
|
||||||
user_name=user_name,
|
|
||||||
input_device_index=audio_device
|
input_device_index=audio_device
|
||||||
)
|
)
|
||||||
self.transcription_engine.set_callbacks(
|
self.transcription_engine.set_callbacks(
|
||||||
@@ -431,7 +430,7 @@ class MainWindow(QMainWindow):
|
|||||||
initial_prompt=self.config.get('transcription.initial_prompt', ''),
|
initial_prompt=self.config.get('transcription.initial_prompt', ''),
|
||||||
no_log_file=self.config.get('transcription.no_log_file', True),
|
no_log_file=self.config.get('transcription.no_log_file', True),
|
||||||
input_device_index=audio_device,
|
input_device_index=audio_device,
|
||||||
user_name=user_name
|
app_config=self.config
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set up callbacks for transcription results
|
# Set up callbacks for transcription results
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class TranscriptionCLI:
|
|||||||
initial_prompt=self.config.get('transcription.initial_prompt', ''),
|
initial_prompt=self.config.get('transcription.initial_prompt', ''),
|
||||||
no_log_file=True,
|
no_log_file=True,
|
||||||
input_device_index=audio_device,
|
input_device_index=audio_device,
|
||||||
user_name=user_name
|
app_config=self.config
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set up callbacks
|
# Set up callbacks
|
||||||
|
|||||||
Reference in New Issue
Block a user