Utility functions
| 194 | |
| 195 | // Utility functions |
| 196 | std::string formatTimestamp(float Seconds) { |
| 197 | assert(Seconds >= 0); |
| 198 | int Milliseconds = static_cast<int>(std::round(Seconds * 1000.0f)); |
| 199 | |
| 200 | int Hours = Milliseconds / 3600000; |
| 201 | Milliseconds -= Hours * 3600000; |
| 202 | |
| 203 | int Minutes = Milliseconds / 60000; |
| 204 | Milliseconds -= Minutes * 60000; |
| 205 | |
| 206 | int Secs = Milliseconds / 1000; |
| 207 | Milliseconds -= Secs * 1000; |
| 208 | |
| 209 | std::stringstream Ss; |
| 210 | if (Hours > 0) { |
| 211 | Ss << std::setfill('0') << std::setw(2) << Hours << ":"; |
| 212 | } |
| 213 | Ss << std::setfill('0') << std::setw(2) << Minutes << ":" << std::setfill('0') |
| 214 | << std::setw(2) << Secs << "." << std::setfill('0') << std::setw(3) |
| 215 | << Milliseconds; |
| 216 | |
| 217 | return Ss.str(); |
| 218 | } |
| 219 | |
| 220 | std::optional<float> getEnd(const std::vector<TranscribeSegment> &Segments) { |
| 221 | for (auto It = Segments.rbegin(); It != Segments.rend(); ++It) { |