diff src/chat.js @ 46:cc20eebaa74a

use openai tts
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 14 Aug 2025 11:27:34 +0900
parents 1d9d9786d76f
children 97b0d206cacd
line wrap: on
line diff
--- a/src/chat.js	Wed Aug 13 10:31:24 2025 +0900
+++ b/src/chat.js	Thu Aug 14 11:27:34 2025 +0900
@@ -3,11 +3,10 @@
 let chat;
 
 function setChat(newChat) {
-	let audioChanged = chat && (chat.language_region != newChat.language_region || chat.voice != newChat.voice);
+	let audioChanged = chat && chat.voice != newChat.voice;
 	chat = newChat;
 	document.querySelector('[content] [name]').textContent = chat.name;
 	if(audioChanged) {
-		let lang = `lang=${chat.language_region}&`;
 		let voice = `voice=${chat.voice}&`;
 		let audios = document.querySelectorAll('audio[src]');
 		for( let audio of audios ) {
@@ -22,7 +21,6 @@
 function editChat(name) {
 	let dialog = document.querySelector('dialog[edit]');
 	dialog.querySelector('input[name=name]').value = chat.name;
-	dialog.querySelector('select[name=language_region]').value = chat.language_region;
 	dialog.querySelector('select[name=voice]').value = chat.voice;
 	dialog.querySelector('input[name=show_text]').checked = chat.show_text;
 	dialog.querySelector('input[name=autoplay]').checked = chat.autoplay;
@@ -67,7 +65,7 @@
 }
 
 function handleChatMarkdown() {
-	handleMarkdown(chat.language_region,chat.voice);
+	handleMarkdown(chat.voice,chat.tts_instructions);
 }
 
 function scrollToEnd() {
@@ -100,7 +98,7 @@
 	textarea.parentNode.scrollIntoViewIfNeeded(false);
 	if( !audio )
 		audio = document.querySelector('div[buttons] audio');
-	audio.src = `/tts.mp3?lang=${chat.language_region}&voice=${chat.voice}&text=${encodeURIComponent(textarea.value)}`;
+	audio.src = `/tts.mp3?voice=${chat.voice}&instructions=${encodeURIComponent(chat.tts_instructions)}&text=${encodeURIComponent(textarea.value)}`;
 }
 
 function askAi() {