|
21 | 21 | from aai_cli.core import choices, client, config_builder, youtube |
22 | 22 | from aai_cli.core.errors import UsageError |
23 | 23 | from aai_cli.core.microphone import MicrophoneSource |
| 24 | +from aai_cli.streaming import turn_presets |
24 | 25 | from aai_cli.streaming.macos import MacSystemAudioSource |
25 | 26 | from aai_cli.streaming.render import StreamRenderer |
26 | 27 | from aai_cli.streaming.session import ( |
|
30 | 31 | validate_sources, |
31 | 32 | ) |
32 | 33 | from aai_cli.streaming.sources import TARGET_RATE, FileSource, StdinSource |
| 34 | +from aai_cli.streaming.turn_presets import TurnDetectionPreset |
33 | 35 | from aai_cli.ui import output |
34 | 36 | from aai_cli.ui.follow import FollowRenderer |
35 | 37 |
|
@@ -57,6 +59,7 @@ class StreamOptions: |
57 | 59 | end_of_turn_confidence_threshold: float | None |
58 | 60 | min_turn_silence: int | None |
59 | 61 | max_turn_silence: int | None |
| 62 | + turn_detection: TurnDetectionPreset | None |
60 | 63 | vad_threshold: float | None |
61 | 64 | format_turns: bool | None |
62 | 65 | include_partial_turns: bool | None |
@@ -93,15 +96,21 @@ def source_options(self) -> SourceOptions: |
93 | 96 |
|
94 | 97 | def base_flags(self) -> dict[str, object]: |
95 | 98 | """Every streaming flag except sample_rate, which is set per source at stream time.""" |
| 99 | + end_of_turn_confidence_threshold, min_turn_silence, max_turn_silence = turn_presets.resolve( |
| 100 | + self.turn_detection, |
| 101 | + self.end_of_turn_confidence_threshold, |
| 102 | + self.min_turn_silence, |
| 103 | + self.max_turn_silence, |
| 104 | + ) |
96 | 105 | flags: dict[str, object] = { |
97 | 106 | "speech_model": config_builder.enum_value(self.speech_model), |
98 | 107 | "format_turns": self.format_turns if self.format_turns is not None else True, |
99 | 108 | "encoding": config_builder.enum_value(self.encoding), |
100 | 109 | "language_detection": self.language_detection, |
101 | 110 | "domain": self.domain, |
102 | | - "end_of_turn_confidence_threshold": self.end_of_turn_confidence_threshold, |
103 | | - "min_turn_silence": self.min_turn_silence, |
104 | | - "max_turn_silence": self.max_turn_silence, |
| 111 | + "end_of_turn_confidence_threshold": end_of_turn_confidence_threshold, |
| 112 | + "min_turn_silence": min_turn_silence, |
| 113 | + "max_turn_silence": max_turn_silence, |
105 | 114 | "vad_threshold": self.vad_threshold, |
106 | 115 | "include_partial_turns": self.include_partial_turns, |
107 | 116 | "keyterms_prompt": list(self.keyterms_prompt) if self.keyterms_prompt else None, |
|
0 commit comments