Return Transcription JSON on handlePostTranscription

This commit is contained in:
FTCHD
2024-01-05 16:17:07 +02:00
parent ab243c9a00
commit 543ecf534b

View File

@@ -101,9 +101,20 @@ func (s *Server) handlePostTranscription(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusInternalServerError, "Internal server error") return fiber.NewError(fiber.StatusInternalServerError, "Internal server error")
} }
// Write the JSON to the response body. // Broadcast transcription to websocket clients
s.BroadcastTranscription(res) s.BroadcastTranscription(res)
s.NewTranscriptionCh <- true s.NewTranscriptionCh <- true
// Convert the transcription to JSON.
json, err := json.Marshal(res)
if err != nil {
// 503 On vacation!
return fiber.NewError(fiber.StatusServiceUnavailable, "On vacation!")
}
// Write the JSON to the response body.
c.Set("Content-Type", "application/json")
c.Write(json)
return nil return nil
} }