-
-
Notifications
You must be signed in to change notification settings - Fork 678
Expand file tree
/
Copy pathTurnDetection.php
More file actions
60 lines (52 loc) · 1.51 KB
/
Copy pathTurnDetection.php
File metadata and controls
60 lines (52 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace OpenAI\Responses\Realtime\Session;
use OpenAI\Contracts\ResponseContract;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Testing\Responses\Concerns\Fakeable;
/**
* @phpstan-type TurnDetectionType array{prefix_padding_ms: int, silence_duration_ms: int, threshold: float, type: 'server_vad'}
*
* @implements ResponseContract<TurnDetectionType>
*/
final class TurnDetection implements ResponseContract
{
/**
* @use ArrayAccessible<TurnDetectionType>
*/
use ArrayAccessible;
use Fakeable;
/**
* @param 'server_vad' $type
*/
private function __construct(
public readonly int $prefixPaddingMs,
public readonly int $silenceDurationMs,
public readonly float $threshold,
public readonly string $type,
) {}
/**
* @param TurnDetectionType $attributes
*/
public static function from(array $attributes): self
{
return new self(
prefixPaddingMs: $attributes['prefix_padding_ms'],
silenceDurationMs: $attributes['silence_duration_ms'],
threshold: $attributes['threshold'],
type: $attributes['type'],
);
}
/**
* {@inheritDoc}
*/
public function toArray(): array
{
return [
'prefix_padding_ms' => $this->prefixPaddingMs,
'silence_duration_ms' => $this->silenceDurationMs,
'threshold' => $this->threshold,
'type' => $this->type,
];
}
}