| 149 | } |
| 150 | |
| 151 | std::string format_srt( |
| 152 | const std::vector<runtime::WordTimestamp> & words, |
| 153 | const SubtitleFormatOptions & options) { |
| 154 | const auto blocks = build_subtitle_blocks(words, options); |
| 155 | std::ostringstream out; |
| 156 | for (const auto & block : blocks) { |
| 157 | out << block.index << "\n" |
| 158 | << format_time(block.span.start_sample, options.sample_rate) |
| 159 | << " --> " |
| 160 | << format_time(block.span.end_sample, options.sample_rate) |
| 161 | << "\n"; |
| 162 | for (const auto & line : block.lines) { |
| 163 | out << line << "\n"; |
| 164 | } |
| 165 | out << "\n"; |
| 166 | } |
| 167 | return out.str(); |
| 168 | } |
| 169 | |
| 170 | } // namespace engine::text |