@stellartech/voice-widget-directus 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +21 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -456,6 +456,26 @@ const VOICE_MODELS = [
456
456
  ];
457
457
  const SAMPLE_TEXT = "Hello! This is a sample of my voice. I hope you enjoy listening to how I sound.";
458
458
  const DEFAULT_FLOW_ID = "7fa08903-ed7d-4632-81fc-f422d873b8f8";
459
+ function splitMarkdownBySeparator(mdText, sep = "## ") {
460
+ const text = String(mdText || "");
461
+ if (!text.includes(sep)) {
462
+ return [text];
463
+ }
464
+ const sections = [];
465
+ let buffer = [];
466
+ let sawHeader = false;
467
+ for (const line of text.split("\n")) {
468
+ if (line.startsWith(sep)) {
469
+ if (sawHeader) sections.push(buffer.join("\n"));
470
+ sawHeader = true;
471
+ buffer = [line];
472
+ } else {
473
+ buffer.push(line);
474
+ }
475
+ }
476
+ if (sawHeader) sections.push(buffer.join("\n"));
477
+ return sections.filter((s) => s.trim().length > 0);
478
+ }
459
479
  function useVoicingApi(api) {
460
480
  async function fetchVoices(collection = "Voices") {
461
481
  try {
@@ -606,10 +626,7 @@ function useVoicingApi(api) {
606
626
  if (!textContent.trim()) {
607
627
  throw new Error("No text content available for voiceover generation");
608
628
  }
609
- texts = textContent.split(/\n\n+/).filter((t) => t.trim().length > 0);
610
- if (texts.length === 0) {
611
- texts = [textContent];
612
- }
629
+ texts = splitMarkdownBySeparator(textContent);
613
630
  console.log(`[Voice Widget] Generating voiceover for "${lessonTitle}" with ${texts.length} text segments`);
614
631
  } catch (e) {
615
632
  console.error("Failed to fetch lesson text content:", e);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stellartech/voice-widget-directus",
3
3
  "description": "Voice generation widget with model/voice selection and audio preview for Directus",
4
4
  "icon": "mic",
5
- "version": "1.0.8",
5
+ "version": "1.0.9",
6
6
  "license": "MIT",
7
7
  "readme": "README.md",
8
8
  "repository": {