v106: коррекция слогов по амплитуде аудио — находим реальное начало речи

This commit is contained in:
“Naeel”
2026-05-23 17:14:45 +04:00
parent 6fe6f77c07
commit 2d94980038
4 changed files with 142 additions and 122 deletions
+11
View File
@@ -89,12 +89,23 @@ async function doCompare(blob, originalText, duration) {
// Слоги — в отдельный div, не в diff (diff перезаписывается)
_currentBlob = blob;
_currentSylBuf = null;
_speechOnset = 0;
_speechEnd = 0;
_currentSylMap = whisperResult.words && whisperResult.words.length > 0
? mapSyllablesToTimestamps(originalText, whisperResult.words)
: null;
console.log('[SYL] map:', _currentSylMap);
const sylDiv = document.getElementById('syllables');
sylDiv.innerHTML = '';
// Показываем отладочную инфу: диапазон речи и первый/последний слог
if (_currentSylMap && _currentSylMap.length > 0) {
const first = _currentSylMap[0], last = _currentSylMap[_currentSylMap.length - 1];
const dbg = document.createElement('div');
dbg.style.cssText = 'font-size:0.7em;color:#aaa;margin-top:2px';
dbg.textContent = '⏱ речь: ' + (first.start||0).toFixed(2) + '' + (last.end||0).toFixed(2) + 'с | ' +
_currentSylMap.map(s => s.syl + '[' + (s.start||0).toFixed(2) + ']').join(' ');
sylDiv.appendChild(dbg);
}
const sy = syllabifyIT(originalText);
if (sy && sy.includes('-')) {
const syls = sy.split('-');