diff --git a/README.md b/README.md index 7bef774..fa45ade 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Contributions are welcome! Feel free to open a PR with your changes, or take a l ### Development setup -Check out the development documentation [here](https://whishper.net/guides/development/). +Check out the development documentation [here](https://whishper.net/guides/develop/). ## Screenshots diff --git a/backend/api/handlers.go b/backend/api/handlers.go index ff877f1..586daa2 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -101,9 +101,20 @@ func (s *Server) handlePostTranscription(c *fiber.Ctx) 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.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 } diff --git a/frontend/src/lib/utils.js b/frontend/src/lib/utils.js index a039cc2..3c3e117 100644 --- a/frontend/src/lib/utils.js +++ b/frontend/src/lib/utils.js @@ -102,13 +102,13 @@ export const downloadVTT = function (jsonData, title) { jsonData.forEach((segment, index) => { let startSeconds = Math.floor(segment.start); let startMillis = Math.floor((segment.start - startSeconds) * 1000); - let start = new Date(startSeconds * 1000 + startMillis).toISOString().substr(11, 12).replace('.', ','); + let start = new Date(startSeconds * 1000 + startMillis).toISOString().substr(11, 12); let endSeconds = Math.floor(segment.end); let endMillis = Math.floor((segment.end - endSeconds) * 1000); - let end = new Date(endSeconds * 1000 + endMillis).toISOString().substr(11, 12).replace('.', ','); + let end = new Date(endSeconds * 1000 + endMillis).toISOString().substr(11, 12); - vttContent += `${index + 1}\n${start} --> ${end}\n- ${segment.text}\n\n`; + vttContent += `${index + 1}\n${start} --> ${end}\n${segment.text}\n\n`; }); let vttBlob = new Blob([vttContent], {type: 'text/plain'}); @@ -118,4 +118,4 @@ export const downloadVTT = function (jsonData, title) { link.download = `${title}.vtt`; link.click(); } - \ No newline at end of file +