diff --git a/index.html b/index.html
index a3b0643..32d4c7b 100644
--- a/index.html
+++ b/index.html
@@ -35,10 +35,6 @@
if (!window.imagePatterns) {
window.imagePatterns = [
{ pattern: /```image\n([\s\S]*?)\n```/i, group: 1 },
- { pattern: /image:\s*(.+)/i, group: 1 },
- { pattern: /show me\s+(.+)/i, group: 1 },
- { pattern: /generate (?:an |a )?image of\s+(.+)/i, group: 1 },
- { pattern: /picture of\s+(.+)/i, group: 1 },
];
}
if (!window.audioPatterns) {
@@ -51,6 +47,16 @@
{ pattern: /```ui\n([\s\S]*?)\n```/i, group: 1 },
];
}
+ if (!window.voicePatterns) {
+ window.voicePatterns = [
+ { pattern: /```voice\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
+ if (!window.videoPatterns) {
+ window.videoPatterns = [
+ { pattern: /```video\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
}
} catch (e) { console.warn('polliLib configure failed', e); }
})();
diff --git a/js/chat/chat-core.js b/js/chat/chat-core.js
index a39d8d9..6d3f02f 100644
--- a/js/chat/chat-core.js
+++ b/js/chat/chat-core.js
@@ -623,6 +623,37 @@ document.addEventListener("DOMContentLoaded", () => {
});
}
+ const videoPatterns = window.videoPatterns || [];
+ for (const { pattern, group } of videoPatterns) {
+ const grpIndex = typeof group === 'number' ? group : 1;
+ const p = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags + 'g');
+ aiContent = aiContent.replace(p, function () {
+ const args = arguments;
+ const prompt = args[grpIndex] && args[grpIndex].trim();
+ if (!prompt) return '';
+ // Video handling to be implemented
+ return '';
+ });
+ }
+
+ const voicePatterns = window.voicePatterns || [];
+ for (const { pattern, group } of voicePatterns) {
+ const grpIndex = typeof group === 'number' ? group : 1;
+ const p = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags + 'g');
+ const matches = Array.from(aiContent.matchAll(p));
+ for (const match of matches) {
+ const text = match[grpIndex] && match[grpIndex].trim();
+ if (!text) continue;
+ try {
+ const sentences = text.split(/(?<=[.!?])\s+/).filter(s => s.trim().length > 0);
+ speakSentences(sentences);
+ } catch (e) {
+ console.warn('speakSentences failed', e);
+ }
+ }
+ aiContent = aiContent.replace(p, '');
+ }
+
aiContent = aiContent.replace(/\n{2,}/g, '\n').trim();
}