andito HF Staff Claude Sonnet 4.5 commited on
Commit
0e8835b
·
1 Parent(s): 1251757

Try COEP credentialless without COOP for SharedArrayBuffer

Browse files

Using only COEP: credentialless should enable SharedArrayBuffer
without breaking iframe embedding (no COOP required).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Files changed (3) hide show
  1. README.md +2 -0
  2. _headers +3 -0
  3. source/src/utils/progressive-streaming.js +11 -39
README.md CHANGED
@@ -5,6 +5,8 @@ colorFrom: blue
5
  colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
  # Parakeet STT Progressive Transcription Demo
 
5
  colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ custom_headers:
9
+ cross-origin-embedder-policy: credentialless
10
  ---
11
 
12
  # Parakeet STT Progressive Transcription Demo
_headers ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ /*
2
+ Cross-Origin-Embedder-Policy: require-corp
3
+ Cross-Origin-Opener-Policy: same-origin
source/src/utils/progressive-streaming.js CHANGED
@@ -99,52 +99,24 @@ export class SmartProgressiveStreamingHandler {
99
  // Window is too large - need to slide it
100
  const cutoffTime = windowDuration - this.sentenceBuffer;
101
 
102
- // Try to fix sentences at natural boundaries
103
- if (result.sentences && result.sentences.length > 1) {
104
- const newFixedSentences = [];
105
- let newFixedEndTime = this.fixedEndTime;
106
-
107
- for (const sentence of result.sentences) {
108
- const sentenceAbsTime = this.fixedEndTime + sentence.end;
109
-
110
- if (sentence.end < cutoffTime) {
111
- // Fix this sentence
112
- newFixedSentences.push(sentence.text.trim());
113
- newFixedEndTime = sentenceAbsTime;
114
- } else {
115
- break;
116
- }
117
- }
118
 
119
- if (newFixedSentences.length > 0) {
120
- this.fixedSentences.push(...newFixedSentences);
121
- this.fixedEndTime = newFixedEndTime;
122
 
123
  // Re-transcribe from new fixed point
124
  const newWindowStartSamples = Math.floor(this.fixedEndTime * this.sampleRate);
125
  const newAudioWindow = audio.slice(newWindowStartSamples);
126
  result = await this.model.transcribe(newAudioWindow);
127
  }
128
- } else {
129
- // No sentence boundaries detected - force slide by word count or time
130
- // Split the current text at roughly the cutoff point
131
- if (result.words && result.words.length > 0) {
132
- // Find words that end before cutoff
133
- const wordsToFix = result.words.filter(w => w.end_time < cutoffTime);
134
-
135
- if (wordsToFix.length > 0) {
136
- const fixedText = wordsToFix.map(w => w.text).join(' ');
137
- const lastWordTime = wordsToFix[wordsToFix.length - 1].end_time;
138
-
139
- this.fixedSentences.push(fixedText.trim());
140
- this.fixedEndTime = this.fixedEndTime + lastWordTime;
141
-
142
- // Re-transcribe from new fixed point
143
- const newWindowStartSamples = Math.floor(this.fixedEndTime * this.sampleRate);
144
- const newAudioWindow = audio.slice(newWindowStartSamples);
145
- result = await this.model.transcribe(newAudioWindow);
146
- }
147
- }
148
  }
149
  }
150
 
 
99
  // Window is too large - need to slide it
100
  const cutoffTime = windowDuration - this.sentenceBuffer;
101
 
102
+ // Always try word-level fallback for more aggressive sliding
103
+ // This ensures window slides even without sentence boundaries
104
+ if (result.words && result.words.length > 0) {
105
+ // Find words that end before cutoff
106
+ const wordsToFix = result.words.filter(w => w.end_time < cutoffTime);
107
+
108
+ if (wordsToFix.length > 0) {
109
+ const fixedText = wordsToFix.map(w => w.text).join(' ');
110
+ const lastWordTime = wordsToFix[wordsToFix.length - 1].end_time;
 
 
 
 
 
 
 
111
 
112
+ this.fixedSentences.push(fixedText.trim());
113
+ this.fixedEndTime = this.fixedEndTime + lastWordTime;
 
114
 
115
  // Re-transcribe from new fixed point
116
  const newWindowStartSamples = Math.floor(this.fixedEndTime * this.sampleRate);
117
  const newAudioWindow = audio.slice(newWindowStartSamples);
118
  result = await this.model.transcribe(newAudioWindow);
119
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
121
  }
122