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 }