Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/engine/models/breeze_tts/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ struct BreezeGenerationRequest {
uint64_t seed = 0;
};

struct BreezeStreamStep {
std::vector<int32_t> new_codes;
int64_t new_frames = 0;
bool done = false;
};

class BreezeGeneratorRuntime {
public:
BreezeGeneratorRuntime(
Expand All @@ -43,6 +49,16 @@ class BreezeGeneratorRuntime {
engine::runtime::AudioBuffer generate(const BreezeGenerationRequest & request);
BreezeSpeechCodes encode_reference(const engine::runtime::AudioBuffer & audio) const;

// Resumable sub-chunk streaming. begin_stream runs prompts + prefills;
// step_stream runs up to max_new_frames AR frames; end_stream releases
// graphs. Only one stream may be active at a time. decode_codes runs the
// codec over a code prefix without releasing graphs (caller brackets with
// begin/end_stream).
void begin_stream(const BreezeGenerationRequest & request);
BreezeStreamStep step_stream(size_t max_new_frames);
void end_stream();
engine::runtime::AudioBuffer decode_codes(const std::vector<int32_t> & codes, int64_t frames);

private:
struct Impl;
std::unique_ptr<Impl> impl_;
Expand Down
9 changes: 9 additions & 0 deletions include/engine/models/breeze_tts/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,20 @@ class BreezeTTSSession final
std::unique_ptr<BreezeGeneratorRuntime> generator_;
engine::runtime::CacheSlots<ReferenceCacheKey, ReferenceCacheEntry, ReferenceCacheKeyEqual> reference_cache_;
std::optional<ReferenceCacheEntry> uncached_reference_;
std::optional<engine::runtime::StreamEvent> next_subchunk_event();
std::vector<engine::runtime::TaskRequest> stream_chunk_requests_;
std::optional<BreezeSpeechCodes> stream_reference_codes_;
engine::runtime::AudioBuffer stream_merged_audio_;
size_t stream_chunk_index_ = 0;
bool stream_started_ = false;
bool stream_subchunk_ = false;
size_t stream_frames_per_event_ = 32;
int64_t stream_lookahead_margin_ = 12;
bool stream_chunk_active_ = false;
std::vector<int32_t> stream_codes_;
int64_t stream_total_frames_ = 0;
size_t stream_emitted_samples_ = 0;
size_t stream_event_seq_ = 0;
};

} // namespace engine::models::breeze_tts
23 changes: 23 additions & 0 deletions model_specs/breeze_tts.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,29 @@
"required": false,
"min": 0,
"default": 0
},
{
"name": "stream_subchunk",
"type": "bool",
"description": "Emit sub-chunk streaming events (multiple audio deltas per text chunk) instead of one event per chunk.",
"required": false,
"default": false
},
{
"name": "stream_frames_per_event",
"type": "int",
"description": "Acoustic frames generated per sub-chunk streaming event.",
"required": false,
"min": 1,
"default": 32
},
{
"name": "stream_lookahead_margin",
"type": "int",
"description": "Trailing codec frames withheld from emission to absorb convolutional boundary artifacts.",
"required": false,
"min": 0,
"default": 12
}
],
"session": [
Expand Down
Loading
Loading