Keep live Whisper segments on screen without a page refresh.
Treat streamed chunks as appends, stop Livewire from remorphing the Alpine tree, and hydrate from HTTP while a run is active so segment cards appear as they arrive.
This commit is contained in:
@@ -155,6 +155,42 @@ class WhisperTranscriptionStreamTest extends TestCase
|
||||
$this->assertSame(-0.3, $event['whisper']['segments'][0]['avg_logprob']);
|
||||
}
|
||||
|
||||
public function test_live_segment_with_nested_segments_array_appends_instead_of_replacing(): void
|
||||
{
|
||||
$first = $this->stream->parseEvent(json_encode([
|
||||
'language' => 'en',
|
||||
'duration' => 6.3,
|
||||
'id' => 0,
|
||||
'start' => 254.5,
|
||||
'end' => 260.8,
|
||||
'text' => "didn't I wasn't aware",
|
||||
'segments' => [
|
||||
['id' => 0, 'start' => 254.5, 'end' => 260.8, 'text' => "didn't I wasn't aware"],
|
||||
],
|
||||
]));
|
||||
$second = $this->stream->parseEvent(json_encode([
|
||||
'language' => 'en',
|
||||
'duration' => 6.96,
|
||||
'id' => 0,
|
||||
'start' => 260.8,
|
||||
'end' => 267.4,
|
||||
'text' => ' other people so I am trying',
|
||||
'segments' => [
|
||||
['id' => 0, 'start' => 260.8, 'end' => 267.4, 'text' => ' other people so I am trying'],
|
||||
],
|
||||
]));
|
||||
|
||||
$this->assertTrue($first['legacy']);
|
||||
$this->assertNull($first['replace']);
|
||||
$this->assertArrayNotHasKey('segments', $first['whisper']);
|
||||
$this->assertSame("didn't I wasn't aware", $first['whisper']['segment']['text']);
|
||||
|
||||
$text = $this->stream->applyEvent('', $first);
|
||||
$text = $this->stream->applyEvent($text, $second);
|
||||
|
||||
$this->assertSame("didn't I wasn't aware other people so I am trying", $text);
|
||||
}
|
||||
|
||||
public function test_joins_legacy_segments_with_spaces(): void
|
||||
{
|
||||
$first = $this->stream->parseEvent('{"text":"Hello from","end":10}');
|
||||
|
||||
Reference in New Issue
Block a user