chrome tts

This commit is contained in:
legop3
2026-06-01 00:56:01 -04:00
parent e108eaa4eb
commit ac93d3227b
15 changed files with 588 additions and 56 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -11,7 +11,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Roomba Rover" />
<title>Roomba Rover</title>
<script type="module" crossorigin src="/assets/index-jVimdn6k.js"></script>
<script type="module" crossorigin src="/assets/index-DbRTVNLN.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CIj_suyF.css">
</head>
<body>
@@ -35,11 +35,22 @@ function normalizeTtsOptions(raw = {}) {
if (!raw || typeof raw !== 'object') return null;
const speak = raw.speak !== false;
if (!speak) return null;
const engine = typeof raw.engine === 'string' && raw.engine.toLowerCase() === 'espeak' ? 'espeak' : 'flite';
const rawEngine = typeof raw.engine === 'string' ? raw.engine.toLowerCase() : '';
const engine = rawEngine === 'espeak' ? 'espeak' : rawEngine === 'chromegtts' ? 'chromegtts' : 'flite';
const voice = typeof raw.voice === 'string' ? raw.voice.trim() : undefined;
let pitch = Number.isFinite(raw.pitch) ? Math.round(raw.pitch) : undefined;
if (typeof pitch === 'number') pitch = Math.max(0, Math.min(99, pitch));
return { speak, engine, voice, pitch };
let pitch = Number.isFinite(raw.pitch) ? raw.pitch : undefined;
let speed = Number.isFinite(raw.speed) ? raw.speed : undefined;
if (engine === 'espeak') {
if (typeof pitch === 'number') pitch = Math.max(0, Math.min(99, Math.round(pitch)));
speed = undefined;
} else if (engine === 'chromegtts') {
if (typeof pitch === 'number') pitch = Math.max(0.5, Math.min(2, pitch));
if (typeof speed === 'number') speed = Math.max(0.5, Math.min(2, speed));
} else {
pitch = undefined;
speed = undefined;
}
return { speak, engine, voice, pitch, speed };
}
function buildAccessNoticeText(mode, reasonText) {
@@ -81,6 +92,7 @@ function maybeSpeak(socket, message, ttsOptions) {
engine: ttsOptions.engine,
voice: ttsOptions.voice,
pitch: ttsOptions.pitch,
speed: ttsOptions.speed,
speak: true,
},
});