tts-v1 / config.json
Shadow0482's picture
Final metadata, texts, config and dataset card
158210d verified
Raw History Blame Contribute Delete
18.7 kB
{
"TARGET_HOURS": 0.1,
"NUM_TTS_WORKERS": 10,
"TTS_BATCH_SIZE": 4,
"LLM_BATCH_SIZE": 32,
"MAX_TTS_VRAM_GB": 7,
"QWEN_MODEL_SIZE": "0.5B",
"AUDIO_FORMAT": "wav",
"SAMPLE_RATE": 24000,
"HF_DATASET_REPO": "Shadow0482/tts-v1",
"HF_PRIVATE": true,
"ENABLE_HF_UPLOAD": true,
"UPLOAD_EVERY_N_SAMPLES": 1500,
"UPLOAD_BATCH_SIZE": 500,
"LANGUAGE": "en",
"ACCENT": "",
"SPEAKER_ID": "speaker_0001",
"SPEAKER_DESCRIPTION": "",
"SEED": 1234,
"GEN_MAX_NEW_TOKENS": 384,
"MIN_WORDS": 5,
"MAX_WORDS": 38,
"MAX_CHARS": 280,
"CHECKPOINT_INTERVAL": 200,
"REPORT_EVERY_S": 30,
"OMNI_STEPS": 20,
"OMNI_GUIDANCE": 2.0,
"OMNI_SPEED": 1.0,
"OMNIVOICE_PRECISION": "f16",
"TTS_BACKEND": "cuda",
"TEXT_STAGE_MODE": "continuous",
"INITIAL_TEXT_BUFFER": 128,
"LLM_BUFFER_TARGET": 512,
"LLM_GPU": null,
"MAX_JOB_RETRIES": 3,
"MAX_AUDIO_SECONDS": 45.0,
"MIN_AUDIO_SECONDS": 0.6,
"MIN_CPS": 4.0,
"MAX_CPS": 40.0,
"PRUNE_INVALID": true,
"RETRY_FAILED_ON_RESTART": false,
"TEXT_UTILS_SRC": "\nimport re, json\nALLOWED_TAGS_EN = [\"[laughter]\", \"[sigh]\", \"[confirmation-en]\", \"[question-en]\", \"[question-ah]\",\n \"[question-oh]\", \"[question-ei]\", \"[question-yi]\", \"[surprise-ah]\", \"[surprise-oh]\",\n \"[surprise-wa]\", \"[surprise-yo]\", \"[dissatisfaction-hnn]\"]\nPROMPT_TAGS_EN = [\"[laughter]\", \"[sigh]\", \"[question-en]\", \"[surprise-oh]\", \"[confirmation-en]\", \"[dissatisfaction-hnn]\"]\nPROMPT_TAGS_OTHER = [\"[laughter]\", \"[sigh]\"]\nTAG_RE = re.compile(r\"\\[[^\\[\\]]{1,40}\\]\")\nTRAIL_TAGS_RE = re.compile(r\"(\\s*\\[[^\\[\\]]{1,40}\\])+\\s*$\")\nBAD_START = re.compile(r\"^(sure|certainly|here (are|is)|of course|as an ai|i'?m sorry|i am sorry|note:|example|output|json|sentence \\d|text \\d)\", re.I)\nBAD_ANY = re.compile(r\"(dataset|text[- ]to[- ]speech|\\btts\\b|language model|\\bjson\\b|as an ai|generated by|\\bprompt\\b|speaker \\d|\\buser:|\\bassistant:|\\bexample\\b)\", re.I)\nUNSAFE = re.compile(r\"\\b(porn\\w*|sexual\\w*|nazi\\w*|rape\\w*|suicid\\w*|kill (myself|yourself)|terroris\\w*|racist\\w*|fuck\\w*|shit\\w*|cunt|nigg\\w*|faggot|molest\\w*|genocide|massacre|cocaine|heroin|bomb\\w*)\\b\", re.I)\nSYMBOLS = re.compile(r\"[*#_`|~<>{}\\\\/@^=+]\")\nWORD_RE = re.compile(r\"[\\w'\\u2019-]+\", re.U)\n\ndef strip_tags(t):\n return re.sub(r\"\\s+\", \" \", TAG_RE.sub(\" \", t)).strip()\n\ndef norm_key(t):\n return re.sub(r\"[^\\w ]\", \"\", strip_tags(t).lower(), flags=re.U).strip()\n\ndef clean_text(raw, language=\"en\", min_words=5, max_words=38, max_chars=280, allowed_tags=None):\n \"\"\"Return (clean_text, None) or (None, reason).\"\"\"\n if allowed_tags is None:\n allowed_tags = ALLOWED_TAGS_EN if language.lower().startswith(\"en\") else [\"[laughter]\", \"[sigh]\"]\n if not isinstance(raw, str):\n return None, \"not_str\"\n t = raw.strip()\n t = re.sub(r\"^\\s*(?:[-*\\u2022]|\\d+[.)])\\s+\", \"\", t)\n t = t.replace(\"\\u201c\", '\"').replace(\"\\u201d\", '\"').replace(\"\\u2018\", \"'\").replace(\"\\u2019\", \"'\")\n t = t.replace(\" \\u2014 \", \", \").replace(\"\\u2014\", \", \").replace(\"\\u2013\", \"-\")\n t = t.strip().strip('\"').strip(\"`\").strip()\n t = TAG_RE.sub(lambda m: m.group(0) if m.group(0).lower() in allowed_tags else \" \", t)\n t = re.sub(r\"\\s+\", \" \", t).strip()\n t = re.sub(r\"\\s+([,.!?;:])\", r\"\\1\", t)\n if '\"' in t:\n t = t.replace('\"', \"\")\n plain = strip_tags(t)\n if not plain:\n return None, \"empty\"\n if re.search(r\"\\d\", plain):\n return None, \"digits\"\n if SYMBOLS.search(plain) or \"http\" in plain.lower() or \"www.\" in plain.lower():\n return None, \"symbols\"\n if BAD_START.search(plain) or BAD_ANY.search(plain):\n return None, \"boilerplate\"\n if UNSAFE.search(plain):\n return None, \"unsafe\"\n words = WORD_RE.findall(plain)\n if not (min_words <= len(words) <= max_words):\n return None, \"length\"\n if len(t) > max_chars:\n return None, \"chars\"\n if not TRAIL_TAGS_RE.sub(\"\", t).rstrip().endswith((\".\", \"!\", \"?\", \"\\u2026\")):\n return None, \"no_end_punct\"\n if language.lower().startswith(\"en\"):\n if sum(c.isascii() for c in plain) / len(plain) < 0.985:\n return None, \"non_ascii\"\n lw = [w.lower() for w in words]\n for i in range(len(lw) - 2):\n if lw[i] == lw[i + 1] == lw[i + 2]:\n return None, \"repeat_word\"\n if len(lw) >= 10 and len(set(lw)) / len(lw) < 0.5:\n return None, \"low_diversity\"\n if sum(1 for c in plain if c in \".!?\") > 6:\n return None, \"too_many_sentences\"\n return t, None\n\ndef parse_candidates(text):\n \"\"\"Extract candidate strings from a model reply; tolerant of malformed JSON.\"\"\"\n if not isinstance(text, str):\n return [], \"empty\"\n s = text.strip()\n i, j = s.find(\"[\"), s.rfind(\"]\")\n if i != -1 and j > i:\n frag = s[i:j + 1]\n try:\n v = json.loads(frag)\n if isinstance(v, list):\n return [x for x in v if isinstance(x, str)], \"json\"\n except Exception:\n pass\n strs = re.findall(r'\"((?:[^\"\\\\]|\\\\.)*)\"', frag)\n if strs:\n out = []\n for x in strs:\n try:\n out.append(json.loads('\"' + x + '\"'))\n except Exception:\n out.append(x)\n return out, \"regex\"\n lines = [l.strip() for l in s.splitlines() if len(l.strip()) > 15]\n return lines, \"lines\"\n\nclass Deduper:\n def __init__(self, window=3000, thresh=0.7):\n self.keys, self.win, self.thresh = set(), [], thresh\n self.window = window\n @staticmethod\n def _sh(key):\n w = key.split()\n return set(zip(w, w[1:], w[2:])) if len(w) >= 3 else {tuple(w)}\n def seen(self, text):\n k = norm_key(text)\n if not k or k in self.keys:\n return True\n sh = self._sh(k)\n for other in self.win:\n u = len(sh | other)\n if u and len(sh & other) / u >= self.thresh:\n return True\n return False\n def add(self, text):\n if self.seen(text):\n return False\n k = norm_key(text)\n self.keys.add(k)\n self.win.append(self._sh(k))\n if len(self.win) > self.window:\n self.win.pop(0)\n return True\n def force_add(self, text):\n k = norm_key(text)\n if k:\n self.keys.add(k)\n self.win.append(self._sh(k))\n if len(self.win) > self.window:\n self.win.pop(0)\n",
"LLM_WORKER_SRC": "\nimport os, sys, json, time, random, re\nsys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))\nfrom omni_text_utils import *\n\ncfg = json.load(open(sys.argv[1]))\nos.environ.setdefault(\"TOKENIZERS_PARALLELISM\", \"false\")\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\ndef log(*a):\n print(time.strftime(\"%H:%M:%S\"), \"[llm]\", *a, flush=True)\n\nTOPICS = [\"a rainy morning commute\", \"learning to cook a favourite family dish\", \"a long train journey\", \"starting a new job\",\n \"a quiet evening at home\", \"growing vegetables on a balcony\", \"a surprise birthday party\", \"an old bookshop\", \"fixing a broken bicycle\",\n \"a thunderstorm at night\", \"a first day at school\", \"planning a small garden\", \"a busy local market\", \"walking along a river\",\n \"a missed bus\", \"a family dinner\", \"learning a musical instrument\", \"a power cut in the evening\", \"moving to a new city\",\n \"a lost umbrella\", \"a childhood memory of summer\", \"waiting at a railway station\", \"a stray cat that visits every day\",\n \"a long phone call with a friend\", \"preparing for an exam\", \"the smell of fresh bread\", \"a crowded festival\", \"a mountain village\",\n \"a broken washing machine\", \"cleaning out an old cupboard\", \"a first snowfall\", \"a lazy Sunday\", \"a football match on television\",\n \"a small neighbourhood shop\", \"teaching someone to swim\", \"an unexpected compliment\", \"the first sip of morning tea\",\n \"a delayed flight\", \"volunteering at a shelter\", \"a new smartphone that confuses everyone\", \"how tides work\", \"why the sky is blue\",\n \"how bees make honey\", \"how to stay calm before a speech\", \"the history of a small town\", \"how a bicycle stays upright\",\n \"why sleep matters\", \"how rainbows form\", \"the joy of finishing a puzzle\", \"a tricky decision\", \"saying sorry to a friend\",\n \"a quiet library\", \"a boat ride at sunset\", \"an old photograph\", \"a neighbour who plays loud music\", \"a first attempt at painting\",\n \"a surprise phone call\", \"the last day of a holiday\", \"a very long queue\", \"a helpful stranger\", \"a favourite song on the radio\"]\nSTYLES = [\"excited\", \"curious\", \"soft and sad\", \"warm and reassuring\", \"lightly humorous\", \"neutral and matter-of-fact\",\n \"thoughtful\", \"encouraging\", \"surprised\", \"calm narration\", \"playful\", \"serious\"]\nFORMS = [\"casual conversational remarks\", \"short narration passages\", \"clear explanations\", \"questions a curious person might ask\",\n \"expressive reactions and exclamations\", \"short pieces of advice\", \"descriptions of a scene\",\n \"small everyday stories told in two sentences\"]\nLANG_NAMES = {\"en\": \"English\", \"hi\": \"Hindi\", \"ta\": \"Tamil\", \"es\": \"Spanish\", \"fr\": \"French\", \"de\": \"German\", \"pt\": \"Portuguese\",\n \"it\": \"Italian\", \"ja\": \"Japanese\", \"zh\": \"Chinese\", \"ar\": \"Arabic\", \"ru\": \"Russian\"}\nEXAMPLE = ['I never thought a quiet walk could clear my head this much.', 'Do you ever wonder why the streets feel different after midnight?']\n\nLANG = cfg[\"language\"]\nlang_name = LANG_NAMES.get(LANG.lower().split(\"-\")[0], LANG)\nlatin_only = LANG.lower().startswith(\"en\")\ntags_pool = PROMPT_TAGS_EN if LANG.lower().startswith(\"en\") else PROMPT_TAGS_OTHER\n\ntexts_path, ctrl_path = cfg[\"texts_path\"], cfg[\"control_path\"]\ndedupe = Deduper()\nfor e in EXAMPLE:\n dedupe.force_add(e)\nseq = 0\nif os.path.exists(texts_path):\n with open(texts_path, \"r\", encoding=\"utf-8\") as f:\n for line in f:\n try:\n r = json.loads(line)\n except Exception:\n continue\n seq = max(seq, int(r.get(\"seq\", 0)))\n dedupe.force_add(r.get(\"text\", \"\"))\nlog(f\"resuming at seq={seq}, known texts={len(dedupe.keys)}\")\n\ntok = AutoTokenizer.from_pretrained(cfg[\"model\"])\ntok.padding_side = \"left\"\nif tok.pad_token is None:\n tok.pad_token = tok.eos_token\nmodel = AutoModelForCausalLM.from_pretrained(cfg[\"model\"], torch_dtype=torch.float16, device_map={\"\": 0}).eval()\nrng = random.Random(cfg[\"seed\"] + seq * 7919)\ntorch.manual_seed(cfg[\"seed\"] + seq * 7919)\nbatch = cfg[\"batch_size\"]\nLENS = [((5, 12), 0.35), ((13, 24), 0.40), ((25, 38), 0.25)]\nstats = dict(calls=0, cands=0, kept=0, parse_fail=0, reasons={})\n\ndef make_prompt():\n topic, style, form = rng.choice(TOPICS), rng.choice(STYLES), rng.choice(FORMS)\n r, acc = rng.random(), 0\n for (lo, hi), p in LENS:\n acc += p\n if r <= acc:\n break\n lo = max(lo, cfg[\"min_words\"]); hi = min(hi, cfg[\"max_words\"])\n accent = f\" Use vocabulary, idioms and spelling natural to {cfg['accent']}.\" if cfg[\"accent\"] else \"\"\n tagc = \"\"\n if rng.random() < 0.3 and style in (\"excited\", \"lightly humorous\", \"playful\", \"soft and sad\", \"surprised\"):\n tagc = (f\" In at most one of the items, you may include exactly one of these markers where it fits naturally: \"\n f\"{', '.join(rng.sample(tags_pool, min(3, len(tags_pool))))}.\")\n user = (f'Write 4 different {form} on the topic \"{topic}\". Tone: {style}. Language: {lang_name}.{accent}\\n'\n f\"Each item must be {lo} to {hi} words of natural spoken language that one person could read aloud. \"\n \"Rules: spell out all numbers (no digits), no emojis, no lists inside an item, no speaker labels, \"\n \"no quotation marks inside an item, plain punctuation, each item ends with . ! or ?. \"\n f\"Make the openings different from each other.{tagc}\\n\"\n f\"Return ONLY a JSON array of 4 strings. Format example (different topic, do not copy): {json.dumps(EXAMPLE)}\")\n msgs = [{\"role\": \"system\", \"content\": \"You write short, natural, speech-ready lines for a speech corpus. You never explain; you only output the requested JSON.\"},\n {\"role\": \"user\", \"content\": user}]\n return tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True), (topic, style, form)\n\ndef control():\n try:\n return json.load(open(ctrl_path))\n except Exception:\n return {\"want_more\": True, \"stop\": False}\n\nparent = os.getppid()\nlast = time.time()\nwhile True:\n c = control()\n if c.get(\"stop\") or os.getppid() != parent:\n log(\"stop requested\"); break\n if not c.get(\"want_more\", True):\n time.sleep(0.5); continue\n prompts, metas = zip(*[make_prompt() for _ in range(batch)])\n try:\n enc = tok(list(prompts), return_tensors=\"pt\", padding=True).to(\"cuda\")\n with torch.no_grad():\n out = model.generate(**enc, do_sample=True, temperature=0.9, top_p=0.95, top_k=50, repetition_penalty=1.08,\n max_new_tokens=cfg[\"max_new_tokens\"], pad_token_id=tok.pad_token_id)\n replies = tok.batch_decode(out[:, enc[\"input_ids\"].shape[1]:], skip_special_tokens=True)\n except torch.cuda.OutOfMemoryError:\n torch.cuda.empty_cache(); batch = max(1, batch // 2); log(f\"OOM -> LLM batch now {batch}\"); continue\n stats[\"calls\"] += 1\n new_rows = []\n for rep, (topic, style, form) in zip(replies, metas):\n cands, how = parse_candidates(rep)\n if how != \"json\":\n stats[\"parse_fail\"] += 1\n for cand in cands:\n stats[\"cands\"] += 1\n t, why = clean_text(cand, LANG, cfg[\"min_words\"], cfg[\"max_words\"], cfg[\"max_chars\"])\n if t is None:\n stats[\"reasons\"][why] = stats[\"reasons\"].get(why, 0) + 1; continue\n if not dedupe.add(t):\n stats[\"reasons\"][\"duplicate\"] = stats[\"reasons\"].get(\"duplicate\", 0) + 1; continue\n seq += 1; stats[\"kept\"] += 1\n new_rows.append({\"id\": f\"{seq:06d}\", \"seq\": seq, \"language\": LANG, \"text\": t, \"topic\": topic, \"style\": style,\n \"form\": form, \"accent\": cfg[\"accent\"], \"gen_model\": cfg[\"model\"], \"gen_format\": how,\n \"created_utc\": time.strftime(\"%Y-%m-%dT%H:%M:%SZ\", time.gmtime())})\n if new_rows:\n with open(texts_path, \"a\", encoding=\"utf-8\") as f:\n f.write(\"\".join(json.dumps(r, ensure_ascii=False) + \"\\n\" for r in new_rows)); f.flush(); os.fsync(f.fileno())\n if time.time() - last > 20 or stats[\"calls\"] == 1:\n last = time.time()\n log(f\"calls={stats['calls']} candidates={stats['cands']} kept={stats['kept']} parse_fail={stats['parse_fail']} \"\n f\"reasons={dict(sorted(stats['reasons'].items(), key=lambda kv: -kv[1])[:6])}\")\n",
"OOM_PAT": "re.compile('out of memory|cudamalloc|failed to allocate|cuda error|cublas_status_alloc|alloc', re.IGNORECASE)",
"WARMUP_TEXT": "Honestly, I did not expect the morning to turn out this well, but here we are, sitting by the window, sipping tea, and watching the rain slowly fade away.",
"REPO_RE": "re.compile('^[A-Za-z0-9][A-Za-z0-9._-]{0,95}/[A-Za-z0-9][A-Za-z0-9._-]{0,95}$')",
"OUT": "/kaggle/working/omnivoice_dataset",
"WORK": "/kaggle/working/_omnivoice_work",
"runtime_url": "https://github.com/0xShug0/audio.cpp/releases/download/v0.9.1/audio-v0.9.1-bin-ubuntu-x64-cuda12.8-colab.tar.gz",
"resolved_sample_rate": 24000,
"voice_route": "voice_ref",
"per_instance": [
{
"instance": 0,
"gpu": 0,
"clips": 9,
"audio_h": 0.0097,
"mem_saver": false,
"measured_vram_mb": 2565,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.15
},
{
"instance": 1,
"gpu": 1,
"clips": 9,
"audio_h": 0.0111,
"mem_saver": false,
"measured_vram_mb": 2565,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.18
},
{
"instance": 2,
"gpu": 0,
"clips": 9,
"audio_h": 0.0113,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.17
},
{
"instance": 3,
"gpu": 1,
"clips": 9,
"audio_h": 0.0128,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.21
},
{
"instance": 4,
"gpu": 0,
"clips": 8,
"audio_h": 0.0157,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.23
},
{
"instance": 5,
"gpu": 1,
"clips": 8,
"audio_h": 0.0131,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.22
},
{
"instance": 6,
"gpu": 0,
"clips": 9,
"audio_h": 0.012,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.18
},
{
"instance": 7,
"gpu": 1,
"clips": 8,
"audio_h": 0.0139,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.23
},
{
"instance": 8,
"gpu": 0,
"clips": 9,
"audio_h": 0.0116,
"mem_saver": false,
"measured_vram_mb": 2562,
"oom_events": 0,
"restarts": 0,
"busy_x_realtime": 0.17
}
],
"llm": "Qwen/Qwen2.5-0.5B-Instruct",
"generated_utc": "2026-10-09T03:10:39Z",
"validation": {
"records": 78,
"valid": 78,
"invalid": 0,
"orphan_audio_files": 0,
"total_hours_valid": 0.1112,
"avg_duration_s": 5.132,
"sample_rates": [
24000
],
"invalid_reasons": {}
}
}