MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / formatTimestamp

Function formatTimestamp

plugins/wasi_nn/MLX/model/whisper_transcribe.cpp:196–218  ·  view source on GitHub ↗

Utility functions

Source from the content-addressed store, hash-verified

194
195// Utility functions
196std::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
220std::optional<float> getEnd(const std::vector<TranscribeSegment> &Segments) {
221 for (auto It = Segments.rbegin(); It != Segments.rend(); ++It) {

Callers 1

transcribeFunction · 0.85

Calls 1

strMethod · 0.80

Tested by

no test coverage detected