Don't send empty dots and spaces

This commit is contained in:
retoor 2025-12-31 10:37:15 +01:00
parent 6250645fa4
commit 3689775efc

View File

@ -132,8 +132,13 @@ class STTButton extends HTMLElement {
text += '.';
}
this._finalTranscript += text + ' ';
this._updateTextarea(this._finalTranscript.trim());
const finalText = this._finalTranscript.trim();
if (this._hasContent(finalText)) {
this._updateTextarea(finalText);
this._finalize();
} else {
this._clearTextarea();
}
this._finalTranscript = '';
this._interimTranscript = '';
} else {
@ -182,9 +187,13 @@ class STTButton extends HTMLElement {
}
}
_hasContent(text) {
return text.replace(/[\s.]+/g, '').length > 0;
}
_finalize() {
const chatInput = this._getChatInput();
if (chatInput) {
if (chatInput && this._hasContent(chatInput.value)) {
chatInput.finalizeMessage();
}
}
@ -277,8 +286,13 @@ class STTButton extends HTMLElement {
}
this._finalTranscript += text + ' ';
}
this._updateTextarea(this._finalTranscript.trim());
const finalText = this._finalTranscript.trim();
if (this._hasContent(finalText)) {
this._updateTextarea(finalText);
this._finalize();
} else {
this._clearTextarea();
}
}
this._stop();