diff --git a/docs/experiments/pocket-text-2026-10-18/README.md b/docs/experiments/pocket-text-2026-10-18/README.md new file mode 100644 index 0000000..3817817 --- /dev/null +++ b/docs/experiments/pocket-text-2026-10-18/README.md @@ -0,0 +1,47 @@ +# Pocket German technical-text preprocessing trial — 18 October 2026 + +Experimental only: no production worker, profile, endpoint or service changed or +restarted. A separate CPU process loaded the same pinned German Pocket weights, +tokenizer and existing private Anna state using the installed CPU runtime. +Strata remained loaded. The process exited after the two syntheses. + +Compared the original user-provided technical answer against speech-only +preprocessing: remove bullet/emphasis/backtick markup, verbalize not-equal, +expand KI/HTTP/403, replace Labeling with Kennzeichnung and speak path separators. +Displayed source remains untouched. Each run resets Torch seed to 42 and copies +the reference state. These are single paired samples, not a quality benchmark. +Actual WAVs were returned to the local Parakeet Redux CPU transcription endpoint. +No browser speech engine used. Audio and full input/transcripts stay outside Git. + +Results: raw 38.40s / 40.24s audio; prepared 30.28s / 38.80s audio. RTF 0.954 +and 0.780. These measurements are not directly comparable to the previous day's +endpoint timings: this is an additional isolated process under current host load. +The prepared round trip correctly retains the first heading, HTTP error number +403 and the crucial phrase “ist nicht gleich echtes Foto”; raw loses them. +Path spelling is still badly reconstructed, and the second paragraph still has +repetitions. This demonstrates partial improvement, not production readiness. +STT is an imperfect intelligibility proxy, not independent listening evidence. + +Official installed Pocket source warns for chunks above 50 tokens: raw 78/57, +prepared 82/60. The installed splitter falls back to comma/semicolon/colon but +still produces oversized sections here. Therefore normalization alone does not +eliminate the potential for omissions. Future work should test shorter spoken +clauses and explicit spelling of opaque identifiers before production activation. + +## Reproduction and restore scope + +`speech_prepare.py` and `test_prepare.py` use only Python's standard library. +Run `python3 test_prepare.py` in this directory (four targeted checks). +`bench.py` expects `input.txt` next to it, an existing Pocket CPU environment and +`/var/lib/deck` containing the pinned public files and private Anna state. Paths +are explicit current-test paths, not a native installer. Use the pinned recipes +in [Pocket TTS](../../POCKET_TTS.md) for runtime/model installation. For another native +state root, change the explicit `state` path before running as its service user. +The harness needs no Docker API; docker exec was only the current deployment's +way of invoking that installed runtime as UID65534. Test output directory must +be writable by that service user. No network/model download is required. + +There is no new production setting or dependency to back up/restore. The private +Anna state stays in the already encrypted speech-voices backup scope. No +credentials, embeddings, audio or user text are committed. No fresh-host native +restore was performed. Do not install this experiment as production code. diff --git a/docs/experiments/pocket-text-2026-10-18/bench.py b/docs/experiments/pocket-text-2026-10-18/bench.py new file mode 100644 index 0000000..bf127a4 --- /dev/null +++ b/docs/experiments/pocket-text-2026-10-18/bench.py @@ -0,0 +1,31 @@ +import os,time,json,copy +from pathlib import Path +os.environ['CUDA_VISIBLE_DEVICES']='' +os.environ['HF_HUB_OFFLINE']='1' +os.environ['TRANSFORMERS_OFFLINE']='1' +import torch,numpy as np,soundfile as sf,yaml,pocket_tts +from pocket_tts import TTSModel +from speech_prepare import prepare +root=Path(__file__).parent +state=Path('/var/lib/deck') +torch.set_num_threads(4) +c=yaml.safe_load((Path(pocket_tts.__file__).parent/'config/german.yaml').read_text()) +c['weights_path']=str(state/'models/4e9d26a79f88e441af30393c08ab141c264916ec87f493c3e80645b20ba9ac7f/model.safetensors') +c['weights_path_without_voice_cloning']=None +c['flow_lm']['lookup_table']['tokenizer_path']=str(state/'models/00da11dace94e5c452998592c8c766ca3d8b111d16cb0deb51799a490ba6d6f5/model.json') +(root/'config.yaml').write_text(yaml.safe_dump(c)) +t=time.monotonic();model=TTSModel.load_model(config=root/'config.yaml');load=time.monotonic()-t +voice=model.get_state_for_audio_prompt(state/'speech-voices/Anna/pocket-german.safetensors') +original=(root/'input.txt').read_text();results={} +for name,text in [('raw',original),('prepared',prepare(original))]: + torch.manual_seed(42) + (root/(name+'.txt')).write_text(text) + start=time.monotonic();chunks=[];first=None + for chunk in model.generate_audio_stream(copy.deepcopy(voice),text): + if first is None:first=time.monotonic()-start + chunks.append(chunk.detach().cpu().numpy().reshape(-1)) + a=np.concatenate(chunks);elapsed=time.monotonic()-start + sf.write(root/(name+'.wav'),a,model.sample_rate) + results[name]=dict(seconds=elapsed,audio_seconds=len(a)/model.sample_rate,rtf=elapsed/(len(a)/model.sample_rate),first_chunk_seconds=first,seed=42) + (root/'results.json').write_text(json.dumps(dict(load_seconds=load,runs=results),indent=2)) + print(json.dumps({name:results[name]}),flush=True) diff --git a/docs/experiments/pocket-text-2026-10-18/results.json b/docs/experiments/pocket-text-2026-10-18/results.json new file mode 100644 index 0000000..cbff310 --- /dev/null +++ b/docs/experiments/pocket-text-2026-10-18/results.json @@ -0,0 +1,19 @@ +{ + "load_seconds": 1.1560502360225655, + "runs": { + "raw": { + "seconds": 38.40030443799333, + "audio_seconds": 40.24, + "rtf": 0.9542819194332337, + "first_chunk_seconds": 0.2977347239793744, + "seed": 42 + }, + "prepared": { + "seconds": 30.27586010401137, + "audio_seconds": 38.8, + "rtf": 0.7803056727837983, + "first_chunk_seconds": 0.36251740099396557, + "seed": 42 + } + } +} \ No newline at end of file diff --git a/docs/experiments/pocket-text-2026-10-18/speech_prepare.py b/docs/experiments/pocket-text-2026-10-18/speech_prepare.py new file mode 100644 index 0000000..0d1c353 --- /dev/null +++ b/docs/experiments/pocket-text-2026-10-18/speech_prepare.py @@ -0,0 +1,16 @@ +"""Experimental German technical speech input; leaves displayed source untouched.""" +import re + +def prepare(text): + def path(match): + value=match.group(0) + return re.sub(r'[/_.-]',lambda m:{'/':' Schrägstrich ','_':' Unterstrich ','-':' Bindestrich ','.':' Punkt '}[m.group()],value) + text=re.sub(r'/[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+)*/?',path,text) + text=re.sub(r'^\s*[-*+]\s+', '',text,flags=re.M) + text=re.sub(r'\*\*(.*?)\*\*',r'\1',text,flags=re.S) + text=text.replace('`','').replace('≠',' ist nicht gleich ') + text=re.sub(r'\bKI\b','Künstliche Intelligenz',text) + text=re.sub(r'\bHTTP\b','Ha Te Te Pe',text) + text=re.sub(r'\b403\b','vierhundertdrei',text) + text=text.replace('Labeling','Kennzeichnung').replace('User-Agent','User Agent') + return re.sub(r'\s+',' ',text).strip() diff --git a/docs/experiments/pocket-text-2026-10-18/test_prepare.py b/docs/experiments/pocket-text-2026-10-18/test_prepare.py new file mode 100644 index 0000000..68ed99a --- /dev/null +++ b/docs/experiments/pocket-text-2026-10-18/test_prepare.py @@ -0,0 +1,8 @@ +import unittest +from speech_prepare import prepare +class Tests(unittest.TestCase): + def test_negation(self):self.assertIn('ist nicht gleich',prepare('KI-Bild ≠ echtes Foto')) + def test_path(self):self.assertEqual(prepare('`/config/ref_imgs/`'),'Schrägstrich config Schrägstrich ref Unterstrich imgs Schrägstrich') + def test_markdown(self):self.assertEqual(prepare('- **Motivwahl:** Hallo.'),'Motivwahl: Hallo.') + def test_numbers(self):self.assertEqual(prepare('403 404 12345'),'vierhundertdrei 404 12345') +unittest.main()