(closeErr error)
| 161 | } |
| 162 | |
| 163 | func (ts *liveTraceState) record(closeErr error) { |
| 164 | if ts == nil || !ts.appConfig.EnableTracing { |
| 165 | return |
| 166 | } |
| 167 | ts.mu.Lock() |
| 168 | data := map[string]any{ |
| 169 | "source": "live_stream", |
| 170 | "language": ts.language, |
| 171 | "result_text": ts.finalText, |
| 172 | "eou_events": ts.eouEvents, |
| 173 | "eob_events": ts.eobEvents, |
| 174 | "delta_events": ts.deltaEvents, |
| 175 | } |
| 176 | if snippet := trace.AudioSnippetFromPCM(ts.pcm, liveSampleRate, ts.fedSamples*2, ts.appConfig.TracingMaxBodyBytes); snippet != nil { |
| 177 | maps.Copy(data, snippet) |
| 178 | } |
| 179 | summary := "live -> " + ts.finalText |
| 180 | ts.mu.Unlock() |
| 181 | |
| 182 | bt := trace.BackendTrace{ |
| 183 | Timestamp: ts.started, |
| 184 | Duration: time.Since(ts.started), |
| 185 | Type: trace.BackendTraceTranscription, |
| 186 | ModelName: ts.modelName, |
| 187 | Backend: ts.backend, |
| 188 | Summary: trace.TruncateString(summary, 200), |
| 189 | Data: data, |
| 190 | } |
| 191 | if closeErr != nil { |
| 192 | bt.Error = closeErr.Error() |
| 193 | } |
| 194 | trace.RecordBackendTrace(bt) |
| 195 | } |
| 196 | |
| 197 | // ModelTranscriptionLive loads the transcription backend, opens the |
| 198 | // bidirectional AudioTranscriptionLive RPC, sends the session config, and |
no test coverage detected