fix: prevent transcription duplication when using cloud provider
This commit is contained in:
parent
74764ac465
commit
dbbc401942
2 changed files with 16 additions and 4 deletions
|
|
@ -312,7 +312,13 @@ export class TranscriptionService {
|
|||
// Accumulate the result only if Whisper returned something
|
||||
// (it returns empty string while buffering)
|
||||
if (chunkTranscription.trim()) {
|
||||
session.transcriptionResults.push(chunkTranscription);
|
||||
// Cloud provider concatenates previousTranscription with new transcription,
|
||||
// so we need to replace the array instead of appending to avoid duplication
|
||||
if (provider.name === "amical-cloud" && aggregatedTranscription) {
|
||||
session.transcriptionResults = [chunkTranscription];
|
||||
} else {
|
||||
session.transcriptionResults.push(chunkTranscription);
|
||||
}
|
||||
logger.transcription.info("Whisper returned transcription", {
|
||||
sessionId,
|
||||
transcriptionLength: chunkTranscription.length,
|
||||
|
|
@ -408,7 +414,13 @@ export class TranscriptionService {
|
|||
});
|
||||
|
||||
if (finalTranscription.trim()) {
|
||||
session.transcriptionResults.push(finalTranscription);
|
||||
// Cloud provider concatenates previousTranscription with new transcription,
|
||||
// so we need to replace the array instead of appending to avoid duplication
|
||||
if (usedCloudProvider && aggregatedTranscription) {
|
||||
session.transcriptionResults = [finalTranscription];
|
||||
} else {
|
||||
session.transcriptionResults.push(finalTranscription);
|
||||
}
|
||||
logger.transcription.info("Whisper returned final transcription", {
|
||||
sessionId,
|
||||
transcriptionLength: finalTranscription.length,
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ namespace WindowsHelper.Services
|
|||
string? postSelectionText = null;
|
||||
Models.SelectionRange? selectionRange = null;
|
||||
|
||||
if (selectionRanges != null && selectionRanges.Length > 0 && !string.IsNullOrEmpty(fullContent))
|
||||
if (selectionRanges != null && selectionRanges.Length > 0 && fullContent != null)
|
||||
{
|
||||
var range = selectionRanges[0];
|
||||
selectedText = SafeGetTextFromRange(range);
|
||||
|
|
@ -523,4 +523,4 @@ namespace WindowsHelper.Services
|
|||
Console.Error.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue