comparison src/site.js @ 46:cc20eebaa74a

use openai tts
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 14 Aug 2025 11:27:34 +0900
parents fef7a5c65cfb
children
comparison
equal deleted inserted replaced
45:fef7a5c65cfb 46:cc20eebaa74a
149 node.remove(); 149 node.remove();
150 } 150 }
151 } 151 }
152 } 152 }
153 153
154 function handleMarkdown(lang,voice) { 154 function handleMarkdown(voice,instructions) {
155 let converter = window.markdownit(); 155 let converter = window.markdownit();
156 let divs = document.querySelectorAll('[markdown]'); 156 let divs = document.querySelectorAll('[markdown]');
157 for( let div of divs ) { 157 for( let div of divs ) {
158 div.innerHTML = converter.render(div.textContent); 158 div.innerHTML = converter.render(div.textContent);
159 toRuby(div); 159 toRuby(div);
164 let rts = mdDiv.querySelectorAll('rt'); 164 let rts = mdDiv.querySelectorAll('rt');
165 for( let rt of rts ) { 165 for( let rt of rts ) {
166 rt.remove(); 166 rt.remove();
167 } 167 }
168 //console.log(mdDiv.textContent); 168 //console.log(mdDiv.textContent);
169 parent.querySelector('audio').src = `/tts.mp3?lang=${lang}&voice=${voice}&text=${encodeURIComponent(mdDiv.textContent)}`; 169 parent.querySelector('audio').src = `/tts.mp3?voice=${voice}&instructions=${encodeURIComponent(instructions)}&text=${encodeURIComponent(mdDiv.textContent)}`;
170 } 170 }
171 } 171 }
172 } 172 }