Skip to content

Commit 46d3d51

Browse files
authored
Merge pull request #43 from robdmac/v2
Fix auto-skip-tts flag and filter log lines
2 parents f6c1eed + 6063b65 commit 46d3d51

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

talkito/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ async def run_claude_wrapper(args) -> int:
361361
'verbosity': args.verbose,
362362
'asr_mode': args.asr_mode,
363363
'record_file': args.record,
364+
'auto_skip_tts': args.auto_skip_tts, # Pass auto-skip-tts flag
364365
}
365366

366367
# Add other configurations...
@@ -579,6 +580,9 @@ def run_mcp_server():
579580

580581
if args.log_file:
581582
config['log_file_path'] = args.log_file
583+
584+
if args.auto_skip_tts:
585+
config['auto_skip_tts'] = True
582586

583587
# Apply configuration
584588
mcp.configure_mcp_server(**config)
@@ -751,6 +755,7 @@ async def run_talkito_command(args) -> int:
751755
'verbosity': args.verbose,
752756
'asr_mode': args.asr_mode,
753757
'record_file': args.record,
758+
'auto_skip_tts': args.auto_skip_tts, # Pass auto-skip-tts flag
754759
}
755760

756761
# Add log file if specified

talkito/mcp.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ def log_message(level: str, message: str):
9898
# Track if we're running for Claude (to mask certain tools)
9999
_running_for_claude = False
100100

101-
def configure_mcp_server(cors_enabled=None, running_for_claude=None, log_file_path=None):
101+
# Track if auto-skip TTS is enabled
102+
_auto_skip_tts = False
103+
104+
def configure_mcp_server(cors_enabled=None, running_for_claude=None, log_file_path=None, auto_skip_tts=None):
102105
"""Configure MCP server settings through a public interface"""
103-
global _cors_enabled, _running_for_claude, _log_file_path
106+
global _cors_enabled, _running_for_claude, _log_file_path, _auto_skip_tts
104107

105108
if cors_enabled is not None:
106109
_cors_enabled = cors_enabled
@@ -111,6 +114,9 @@ def configure_mcp_server(cors_enabled=None, running_for_claude=None, log_file_pa
111114
if log_file_path is not None:
112115
_log_file_path = log_file_path
113116
setup_logging(log_file_path)
117+
118+
if auto_skip_tts is not None:
119+
_auto_skip_tts = auto_skip_tts
114120

115121
def add_cors_headers(headers):
116122
"""Add CORS headers to response"""
@@ -277,7 +283,7 @@ def _ensure_initialization():
277283
engine = tts.detect_tts_engine()
278284
if engine == "none":
279285
raise RuntimeError("No TTS engine found. Please install espeak, festival, flite (Linux) or use macOS")
280-
tts.start_tts_worker(engine, auto_skip_tts=False)
286+
tts.start_tts_worker(engine, auto_skip_tts=_auto_skip_tts)
281287
else:
282288
# Configure and use the selected provider
283289
tts_config = {'provider': best_provider}
@@ -287,9 +293,9 @@ def _ensure_initialization():
287293
engine = tts.detect_tts_engine()
288294
if engine == "none":
289295
raise RuntimeError("No TTS engine found")
290-
tts.start_tts_worker(engine, auto_skip_tts=False)
296+
tts.start_tts_worker(engine, auto_skip_tts=_auto_skip_tts)
291297
else:
292-
tts.start_tts_worker(best_provider, auto_skip_tts=False)
298+
tts.start_tts_worker(best_provider, auto_skip_tts=_auto_skip_tts)
293299

294300
shared_state.set_tts_initialized(True, provider=best_provider)
295301
log_message("INFO", f"TTS initialized with provider: {tts.tts_provider}")
@@ -868,7 +874,7 @@ async def _change_tts_internal(provider: str = "system", voice: str = None, regi
868874
tts.shutdown_tts()
869875

870876
engine = provider if provider != 'system' else tts.detect_tts_engine()
871-
tts.start_tts_worker(engine, auto_skip_tts=False)
877+
tts.start_tts_worker(engine, auto_skip_tts=_auto_skip_tts)
872878

873879
config_parts = [f"provider={provider}"]
874880
if voice: config_parts.append(f"voice={voice}")

talkito/profiles.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ def strip_symbols_from(self, text: str) -> str:
216216
return text.strip()
217217

218218

219+
# Common patterns that should be applied to all profiles
220+
COMMON_SKIP_PATTERNS = [
221+
# Timestamp patterns - filter log lines with timestamps in first 20 chars
222+
(2, r'^.{0,20}\[\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}'), # [YYYY-MM-DD HH:MM:SS format
223+
(2, r'^.{0,20}\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}'), # YYYY-MM-DD HH:MM:SS format (no brackets)
224+
(2, r'^.{0,20}\d{2}:\d{2}:\d{2}'), # HH:MM:SS format in first 20 chars
225+
(2, r'^.{0,20}\d{4}/\d{2}/\d{2}\s+\d{2}:\d{2}:\d{2}'), # YYYY/MM/DD HH:MM:SS format
226+
(2, r'^.{0,20}\d{2}/\d{2}/\d{4}\s+\d{2}:\d{2}:\d{2}'), # MM/DD/YYYY HH:MM:SS format
227+
]
228+
219229
# Profile definitions
220230
CLAUDE_PROFILE = Profile(
221231
name='claude',
@@ -231,7 +241,7 @@ def strip_symbols_from(self, text: str) -> str:
231241
(1, r'\s*✻'), # Interim thinking
232242
(0, r'│ Do'),
233243
],
234-
skip_patterns=[
244+
skip_patterns=COMMON_SKIP_PATTERNS + [
235245
# Level 1: Filter unless -v (tips, hints, usage info, single-word status)
236246
(1, r'[A-Z][a-z]+…'), # Single words like "Sparkling.", "Running."
237247
(1, r'Tip:'), # Tips
@@ -293,7 +303,7 @@ def strip_symbols_from(self, text: str) -> str:
293303

294304
AIDER_PROFILE = Profile(
295305
name='aider',
296-
skip_patterns=[
306+
skip_patterns=COMMON_SKIP_PATTERNS + [
297307
(1, r'^Main model:'),
298308
(1, r'^Editor model:'),
299309
(1, r'^Weak model:'),
@@ -308,7 +318,7 @@ def strip_symbols_from(self, text: str) -> str:
308318

309319
PIPET_PROFILE = Profile(
310320
name='pipet',
311-
skip_patterns=[
321+
skip_patterns=COMMON_SKIP_PATTERNS + [
312322
(1, r'^Analyzing package'),
313323
(1, r'^Package:'),
314324
(1, r'^Version:'),
@@ -319,6 +329,7 @@ def strip_symbols_from(self, text: str) -> str:
319329

320330
PYTHON_PROFILE = Profile(
321331
name='python',
332+
skip_patterns=COMMON_SKIP_PATTERNS,
322333
prompt_patterns=[
323334
r'^>>>\s*', # Python REPL prompt
324335
r'^\.\.\.\s*', # Python continuation prompt
@@ -328,6 +339,7 @@ def strip_symbols_from(self, text: str) -> str:
328339

329340
MYSQL_PROFILE = Profile(
330341
name='mysql',
342+
skip_patterns=COMMON_SKIP_PATTERNS,
331343
prompt_patterns=[
332344
r'^mysql>\s*', # MySQL prompt
333345
r'^->\s*', # MySQL continuation
@@ -337,6 +349,7 @@ def strip_symbols_from(self, text: str) -> str:
337349

338350
PSQL_PROFILE = Profile(
339351
name='psql',
352+
skip_patterns=COMMON_SKIP_PATTERNS,
340353
prompt_patterns=[
341354
r'^\w+=#\s*', # PostgreSQL prompt (database=#)
342355
r'^\w+=-#\s*', # PostgreSQL continuation
@@ -349,7 +362,7 @@ def strip_symbols_from(self, text: str) -> str:
349362
name='default',
350363
response_prefix='',
351364
raw_skip_patterns=[],
352-
skip_patterns=[],
365+
skip_patterns=COMMON_SKIP_PATTERNS,
353366
speak_patterns=[],
354367
prompt_patterns=[],
355368
skip_progress=[],

talkito/tts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,9 @@ def queue_for_speech(text: str, line_number: Optional[int] = None, source: str =
13171317
tts_queue.get_nowait()
13181318
except:
13191319
break
1320-
# Also skip current item if playing
1321-
playback_control.skip_current_item()
1320+
# Only skip current item if something is actually playing
1321+
if playback_control.current_process is not None:
1322+
playback_control.skip_current_item()
13221323

13231324
# Debounce rapidly changing text
13241325
current_time = time.time()
@@ -1363,6 +1364,7 @@ def start_tts_worker(engine: str, auto_skip_tts: bool = False) -> threading.Thre
13631364
"""Start the TTS worker thread"""
13641365
global tts_worker_thread, auto_skip_tts_enabled
13651366
auto_skip_tts_enabled = auto_skip_tts
1367+
log_message("INFO", f"TTS worker started with auto_skip_tts={auto_skip_tts}")
13661368
# Clear the shutdown event in case it was set from a previous shutdown
13671369
shutdown_event.clear()
13681370
tts_worker_thread = threading.Thread(target=tts_worker, args=(engine,), daemon=True)

0 commit comments

Comments
 (0)