From c3bf4d2568b85f190dfece8a65f091e4c9a8eb9f Mon Sep 17 00:00:00 2001 From: Yoshida Hiroshi Date: Fri, 19 Jan 2024 14:09:18 +0900 Subject: [PATCH] =?UTF-8?q?OnResultFunc=20=E3=81=A7=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=82=82=20JSON=20=E3=82=92=E8=BF=94=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amazon_transcribe_handler.go | 4 ++++ speech_to_text_handler.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/amazon_transcribe_handler.go b/amazon_transcribe_handler.go index 3052d75..705b15b 100644 --- a/amazon_transcribe_handler.go +++ b/amazon_transcribe_handler.go @@ -103,6 +103,10 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, reader io.Reader) case *transcribestreamingservice.TranscriptEvent: if h.OnResultFunc != nil { if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, e.Transcript.Results); err != nil { + errResponse := NewSuzuErrorResponse(err.Error()) + if err := encoder.Encode(errResponse); err != nil { + // TODO: ログを書く + } w.CloseWithError(err) return } diff --git a/speech_to_text_handler.go b/speech_to_text_handler.go index 4e3fbcd..7fbe192 100644 --- a/speech_to_text_handler.go +++ b/speech_to_text_handler.go @@ -144,6 +144,10 @@ func (h *SpeechToTextHandler) Handle(ctx context.Context, reader io.Reader) (*io if h.OnResultFunc != nil { if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, resp.Results); err != nil { + errResponse := NewSuzuErrorResponse(err.Error()) + if err := encoder.Encode(errResponse); err != nil { + // TODO: ログを書く + } w.CloseWithError(err) return }