diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..83434a4 --- /dev/null +++ b/.air.toml @@ -0,0 +1,36 @@ +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + +[build] + bin = "suzu-dev" + cmd = "go build -race -o suzu-dev cmd/suzu/main.go" + delay = 1000 + exclude_dir = ["assets", "tmp", "vendor", "testdata"] + exclude_file = [] + exclude_regex = ["_test.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html"] + kill_delay = "0s" + log = "build-errors.log" + send_interrupt = false + stop_on_error = true + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + time = false + +[misc] + clean_on_exit = false + +[screen] + clear_on_rebuild = false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..859820a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release Build + +on: + push: + tags: + - '*' + +jobs: + + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '^1.19' + + - run: go install github.com/tcnksm/ghr@latest + + - name: Build + run: | + GOOS=linux GOARCH=amd64 go build -o dist/suzu_linux_amd64 cmd/suzu/main.go + GOOS=darwin GOARCH=amd64 go build -o dist/suzu_darwin_amd64 cmd/suzu/main.go + GOOS=darwin GOARCH=arm64 go build -o dist/suzu_darwin_arm64 cmd/suzu/main.go + gzip dist/* + + - name: Release + run: | + ghr -t "${{ secrets.GITHUB_TOKEN }}" -u "${{ github.repository_owner }}" -r "suzu" --replace "${GITHUB_REF##*/}" dist/ \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..ca691a5 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,36 @@ +name: Go Build & Test + +on: + push: + branches-ignore: + - 'main' + tags-ignore: + - '*' + +jobs: + + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "^1.19" + + - run: go version + + - run: go fmt . + + - uses: dominikh/staticcheck-action@v1.2.0 + with: + version: "2022.1.3" + install-go: false + + - name: Test + run: make test + + - name: Build + run: make \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..402ff33 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +suzu-dev +tmp/* +bin/* +config.yaml +config.toml +suzu.log +suzu.jsonl +*.pem + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c632b09 --- /dev/null +++ b/LICENSE @@ -0,0 +1,176 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3523e30 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +.PHONY: all + +all: + go build -o bin/suzu cmd/suzu/main.go + +init: + curl -LO https://raw.githubusercontent.com/pion/webrtc/master/pkg/media/oggwriter/oggwriter.go + patch < oggwriter.go.patch + +test: + @go test -v -short --race diff --git a/README.md b/README.md new file mode 100644 index 0000000..d57dfe1 --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# Audio Streaming Gateway Suzu + + +**現在リリースに向けて開発中です** + +[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/shiguredo/suzu.svg)](https://github.com/shiguredo/suzu) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) + +## About Shiguredo's open source software + +We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese. + +Please read https://github.com/shiguredo/oss/blob/master/README.en.md before use. + +## 時雨堂のオープンソースソフトウェアについて + +利用前に https://github.com/shiguredo/oss をお読みください。 + +## Audio Streaming Gateway Suzu について + +Suzu は [WebRTC SFU Sora](https://sora.shiguredo.jp) から音声データを HTTP/2 経由で受け取り、 +音声解析サービスへ送信し解析結果を Sora 経由で DataChannel でクライアントへ通知するゲートウェイです。 + +## 目的 + +リアルタイム通話で気軽に音声解析サービスを利用できる仕組みを提供する事です。 + +## 特徴 + +- Sora から音声データを HTTP/2 経由で受け取り、音声解析サービスへ送信します +- 音声解析サービスの解析結果を HTTP/2 レスポンスで Sora に戻します +- Sora は受け取った解析結果をクライアントへプッシュで送信します + - [DataChannel 経由のシグナリング](https://sora-doc.shiguredo.jp/DATA_CHANNEL_SIGNALING) の利用を推奨します +- 音声解析に必要とされる言語コードをクライアント事に指定可能です +- mTLS 対応 + +## 使ってみる + +Suzu を使ってみたい人は [USE.md](doc/USE.md) をお読みください。 + +## 対応サービス + +- [x] [Amazon Transcribe](https://aws.amazon.com/jp/transcribe/) +- [x] [Google Cloud Speech-to-Text](https://cloud.google.com/speech-to-text) +- [ ] [Microsoft Azure Speech to Text](https://azure.microsoft.com/ja-jp/products/cognitive-services/speech-to-text/) +- [ ] [Microsoft Azure Speech Translation](https://azure.microsoft.com/ja-jp/products/cognitive-services/speech-translation/) +- [ ] [Deepgram](https://deepgram.com/) +- [ ] [AmiVoice Cloud Platform](https://acp.amivoice.com/amivoice/) + +## ライセンス + +``` +Copyright 2022-2022, Hiroshi Yoshida (Original Author) +Copyright 2022-2022, Shiguredo Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +## 優先実装 + +優先実装とは Sora のライセンスを契約頂いているお客様限定で Suzu の実装予定機能を有償にて前倒しで実装することです。 + +### 優先実装が可能な機能一覧 + +詳細は Discord やメールなどでお気軽にお問い合わせください。 + +- [Microsoft Azure Speech to Text](https://azure.microsoft.com/ja-jp/products/cognitive-services/speech-to-text/) 対応 +- [Microsoft Azure Speech Translation](https://azure.microsoft.com/ja-jp/products/cognitive-services/speech-translation/) 対応 +- [Deepgram](https://deepgram.com/) 対応 +- [AmiVoice Cloud Platform](https://acp.amivoice.com/amivoice/) 対応 +- [ggerganov/whisper\.cpp: Port of OpenAI's Whisper model in C/C\+\+](https://github.com/ggerganov/whisper.cpp) 対応 + - Suzu から利用できるようになる Whisper サーバを開発し、OSS として公開します +- ウェブフック機能対応 + - クライアント事に接続先サービスを変更できるようになる diff --git a/amazon_transcribe.go b/amazon_transcribe.go new file mode 100644 index 0000000..e9ec813 --- /dev/null +++ b/amazon_transcribe.go @@ -0,0 +1,190 @@ +package suzu + +import ( + "context" + "fmt" + "io" + "net/http" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/transcribestreamingservice" +) + +type TranscriptionResult struct { + ChannelID *string `json:"channel_id"` + Message []byte `json:"message"` + Error error `json:"error,omitempty"` +} + +const ( + FrameSize = 1024 * 10 +) + +type AmazonTranscribe struct { + LanguageCode string + MediaEncoding string + MediaSampleRateHertz int64 + EnablePartialResultsStabilization bool + NumberOfChannels int64 + EnableChannelIdentification bool + PartialResultsStability string + Region string + Debug bool + StartStreamTranscriptionEventStream *transcribestreamingservice.StartStreamTranscriptionEventStream + ResultCh chan TranscriptionResult +} + +func NewAmazonTranscribe(config Config, languageCode string, sampleRateHertz, audioChannelCount int64) *AmazonTranscribe { + return &AmazonTranscribe{ + Region: config.AwsRegion, + LanguageCode: languageCode, + MediaEncoding: transcribestreamingservice.MediaEncodingOggOpus, + MediaSampleRateHertz: sampleRateHertz, + EnablePartialResultsStabilization: config.AwsEnablePartialResultsStabilization, + PartialResultsStability: config.AwsPartialResultsStability, + NumberOfChannels: audioChannelCount, + EnableChannelIdentification: config.AwsEnableChannelIdentification, + ResultCh: make(chan TranscriptionResult), + } +} + +func NewStartStreamTranscriptionInput(at *AmazonTranscribe) transcribestreamingservice.StartStreamTranscriptionInput { + var numberOfChannels *int64 + if at.EnableChannelIdentification { + numberOfChannels = aws.Int64(at.NumberOfChannels) + } + var partialResultsStability *string + if !at.EnablePartialResultsStabilization { + partialResultsStability = nil + } else { + partialResultsStability = &at.PartialResultsStability + } + + return transcribestreamingservice.StartStreamTranscriptionInput{ + LanguageCode: aws.String(at.LanguageCode), + MediaEncoding: aws.String(transcribestreamingservice.MediaEncodingOggOpus), + MediaSampleRateHertz: aws.Int64(at.MediaSampleRateHertz), + NumberOfChannels: numberOfChannels, + EnablePartialResultsStabilization: aws.Bool(at.EnablePartialResultsStabilization), + PartialResultsStability: partialResultsStability, + EnableChannelIdentification: aws.Bool(at.EnableChannelIdentification), + } +} + +func NewAmazonTranscribeClient(config Config) *transcribestreamingservice.TranscribeStreamingService { + cfg := aws.NewConfig().WithRegion(config.AwsRegion) + + if config.Debug { + cfg = cfg.WithLogLevel(aws.LogDebug) + //cfg = cfg.WithLogLevel(aws.LogDebugWithRequestErrors) + } + + // TODO: 後で変更する + tr := &http.Transport{} + cfg = cfg.WithHTTPClient(&http.Client{Transport: tr}) + + var sess *session.Session + if config.AwsProfile != "" { + sessOpts := session.Options{ + Config: *cfg, + Profile: config.AwsProfile, + SharedConfigFiles: []string{config.AwsCredentialFile}, + SharedConfigState: session.SharedConfigEnable, + } + sess = session.Must(session.NewSessionWithOptions(sessOpts)) + } else { + // デフォルトの HTTPClient の場合は、同時に複数接続する場合に HTTP リクエストがエラーになるため、aws.Config に独自の HTTPClient を指定する + sess = session.Must(session.NewSession(cfg)) + } + return transcribestreamingservice.New(sess, cfg) +} + +func (at *AmazonTranscribe) Start(ctx context.Context, config Config, r io.Reader) error { + if err := at.startTranscribeService(ctx, config); err != nil { + return err + } + + if err := at.streamAudioFromReader(ctx, r, FrameSize); err != nil { + return err + } + + return nil +} + +func (at *AmazonTranscribe) startTranscribeService(ctx context.Context, config Config) error { + + client := NewAmazonTranscribeClient(config) + input := NewStartStreamTranscriptionInput(at) + + resp, err := client.StartStreamTranscriptionWithContext(ctx, &input) + if err != nil { + return err + } + + stream := resp.GetStream() + at.StartStreamTranscriptionEventStream = stream + + go at.ReceiveResults(ctx) + + return nil +} + +func (at *AmazonTranscribe) Close() error { + if at.StartStreamTranscriptionEventStream != nil { + return at.StartStreamTranscriptionEventStream.Close() + } + return nil +} + +func (at *AmazonTranscribe) ReceiveResults(ctx context.Context) { +L: + for { + select { + case <-ctx.Done(): + return + case event := <-at.StartStreamTranscriptionEventStream.Events(): + switch e := event.(type) { + case *transcribestreamingservice.TranscriptEvent: + for _, res := range e.Transcript.Results { + // TODO: debug == true では res.IsPartial == true 時の Transcript も取得する + if !*res.IsPartial { + for _, alt := range res.Alternatives { + var message []byte + if alt.Transcript != nil { + message = []byte(*alt.Transcript) + } + // TODO: 他に必要なフィールドも送信する + at.ResultCh <- TranscriptionResult{ + ChannelID: res.ChannelId, + Message: message, + } + } + } + } + default: + break L + } + } + } + + if err := at.StartStreamTranscriptionEventStream.Err(); err != nil { + err := fmt.Errorf("UNEXPECTED-STREAM-EVENT: %w", err) + at.ResultCh <- TranscriptionResult{ + Error: err, + } + return + } + + // io.EOF の場合は err は nil になるため明示的に io.EOF を送る + at.ResultCh <- TranscriptionResult{ + Error: io.EOF, + } +} + +func (at *AmazonTranscribe) streamAudioFromReader(ctx context.Context, r io.Reader, frameSize int) error { + if err := transcribestreamingservice.StreamAudioFromReader(ctx, at.StartStreamTranscriptionEventStream, frameSize, r); err != nil { + return err + } + return nil +} diff --git a/amazon_transcribe_handler.go b/amazon_transcribe_handler.go new file mode 100644 index 0000000..dfa5087 --- /dev/null +++ b/amazon_transcribe_handler.go @@ -0,0 +1,66 @@ +package suzu + +import ( + "context" + "encoding/json" + "io" + "time" +) + +func init() { + ServiceHandlers.registerHandler("aws", AmazonTranscribeHandler) +} + +func AmazonTranscribeHandler(ctx context.Context, conn io.Reader, args HandlerArgs) (*io.PipeReader, error) { + at := NewAmazonTranscribe(args.Config, args.LanguageCode, int64(args.SampleRate), int64(args.ChannelCount)) + + d := time.Duration(args.Config.TimeToWaitForOpusPacketMs) * time.Millisecond + + reader, err := readerWithSilentPacketFromOpusReader(d, conn) + if err != nil { + return nil, err + } + + oggReader, oggWriter := io.Pipe() + go func() { + if err := opus2ogg(ctx, reader, oggWriter, args.SampleRate, args.ChannelCount, args.Config); err != nil { + oggWriter.CloseWithError(err) + return + } + oggWriter.Close() + }() + + go func() { + defer at.Close() + + if err := at.Start(ctx, args.Config, oggReader); err != nil { + at.ResultCh <- TranscriptionResult{ + Error: err, + } + return + } + }() + + r, w := io.Pipe() + go func() { + encoder := json.NewEncoder(w) + + for tr := range at.ResultCh { + if err := tr.Error; err != nil { + w.CloseWithError(err) + return + } + + res := Response{ + ChannelID: tr.ChannelID, + Message: string(tr.Message), + } + if err := encoder.Encode(res); err != nil { + w.CloseWithError(err) + return + } + } + }() + + return r, nil +} diff --git a/cmd/suzu/main.go b/cmd/suzu/main.go new file mode 100644 index 0000000..f038c1d --- /dev/null +++ b/cmd/suzu/main.go @@ -0,0 +1,75 @@ +package main + +import ( + "context" + "flag" + "fmt" + "log" + "os" + "strings" + + "github.com/shiguredo/suzu" + "golang.org/x/sync/errgroup" +) + +var ( + // git rev-parse --short HEAD + revision string = "air" +) + +var ( + configFilePath string + serviceType string +) + +func init() { + // XXX(v): とりあえず 同じ場所にある config.toml を読みに行く実装 + flag.StringVar(&configFilePath, "C", "config.toml", "suzu の設定ファイルへのパス") + flag.StringVar(&serviceType, "service", "aws", fmt.Sprintf("音声文字変換のサービス(%s)", strings.Join(suzu.ServiceHandlers.GetNames(), ", "))) + flag.Parse() +} + +func main() { + + buf, err := os.ReadFile(configFilePath) + if err != nil { + // 読み込めない場合 Fatal で終了 + log.Fatal("cannot open config file, err=", err) + } + + // toml をパース + var config suzu.Config + if err := suzu.InitConfig(buf, &config); err != nil { + // パースに失敗した場合 Fatal で終了 + log.Fatal("cannot parse config file, err=", err) + } + + // リビジョンを追加 + config.Revision = revision + + // ロガー初期化 + err = suzu.InitLogger(config) + if err != nil { + // ロガー初期化に失敗したら Fatal で終了 + log.Fatal("cannot parse config file, err=", err) + } + + server, err := suzu.NewServer(&config, serviceType) + if err != nil { + log.Fatal("cannot create server:", err) + } + + g, ctx := errgroup.WithContext(context.Background()) + + g.Go(func() error { + return server.Start(ctx, config.ListenAddr, config.ListenPort) + }) + + g.Go(func() error { + return server.StartExporter(ctx, config.ExporterIPAddress, config.ExporterPort) + }) + + if err := g.Wait(); err != nil { + log.Fatal(err) + } +} diff --git a/config.example.toml b/config.example.toml new file mode 100644 index 0000000..6daec10 --- /dev/null +++ b/config.example.toml @@ -0,0 +1,70 @@ +debug = true + +# Suzu の HTTP リクエストの待ち受けアドレスとポートです +listen_addr = "127.0.0.1" +listen_port = 48080 + +exporter_ip_address = "127.0.0.1" +exporter_port = 48081 + +skip_basic_auth = true + +# 音声データのサンプリングレートです +audio_sample_rate = 48000 +# 音声データのチャネル数です +audio_channel_count = 1 + +# 受信した音声データの保存先ファイルです +dump_file = "./dump.jsonl" + +# [http2] +# Suzu のサーバ証明書ファイルです +http2_fullchain_file = "" +# Suzu の秘密鍵ファイルです +http2_privkey_file = "" +# クライアント認証用の CA 証明書ファイルです +http2_verify_cacert_path = "" + +# [log] +# ログの出力先ディレクトリです +log_dir = "." +# ログの出力先ファイルのファイル名です +log_name = "suzu.jsonl" +log_debug = false +# ログを標準出力に出力可否の指定です +log_stdout = true + +# [aws] +aws_region = "ap-northeast-1" +# Partial-result stabilization の有効化です +aws_enable_partial_results_stabilization = false +# 安定化レベルの指定です(high, medium, low) +# aws_partial_results_stability = "low" +# マルチチャネルの音声のチャネル識別の有効化です +aws_enable_channel_identification = false +# 認証情報ファイルの指定です +aws_credential_file = "./credentials" +# プロファイルの指定です +# 認証情報に AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY を使用する場合は、下記のプロファイルの指定行をコメントアウトします +aws_profile = "default" + + +# https://cloud.google.com/speech-to-text/docs/reference/rpc/google.cloud.speech.v1#streamingrecognitionconfig +# https://cloud.google.com/speech-to-text/docs/reference/rpc/google.cloud.speech.v1#recognitionconfig +# [gcp] +# 1 つだけの発話を検出するかの設定です。ture にした場合は 1 つの発話を検出すると、それ以降の発話をテキスト化した結果は返ってきません +gcp_single_utterance = false +# テキスト化の中間結果を返すかの設定です +gcp_interim_results = true +# GCP の認証情報ファイル(JSON)の指定です。GOOGLE_APPLICATION_CREDENTIALS で認証情報ファイルを指定する場合は下記のファイルの指定行をコメントアウトします +gcp_credential_file = "" +# gcp_enable_separate_recognition_per_channel = false +# gcp_alternative_language_codes = [] +# gcp_max_alternatives = 1 +# gcp_profanity_filter = false +# gcp_enable_word_time_offsets = false +# gcp_enable_word_confidence = false +# gcp_enable_automatic_punctuation = false +# gcp_enable_spoken_punctuation = false +# gcp_model = "default" +# gcp_use_enhanced = false \ No newline at end of file diff --git a/config.go b/config.go new file mode 100644 index 0000000..2d60af3 --- /dev/null +++ b/config.go @@ -0,0 +1,84 @@ +package suzu + +import ( + "github.com/BurntSushi/toml" +) + +const ( + // 100ms + DefaultTimeToWaitForOpusPacketMs = 100 +) + +type Config struct { + Revision string + + Debug bool `toml:"debug"` + + ListenAddr string `toml:"listen_addr"` + ListenPort int `toml:"listen_port"` + + HTTP2FullchainFile string `toml:"http2_fullchain_file"` + HTTP2PrivkeyFile string `toml:"http2_privkey_file"` + HTTP2VerifyCacertPath string `toml:"http2_verify_cacert_path"` // クライアント認証用 + + HTTP2MaxConcurrentStreams uint32 `toml:"http2_max_concurrent_streams"` + HTTP2MaxReadFrameSize uint32 `toml:"http2_max_read_frame_size"` + HTTP2IdleTimeout uint32 `toml:"http2_idle_timeout"` + + ExporterIPAddress string `toml:"exporter_ip_address"` + ExporterPort int `toml:"exporter_port"` + + SkipBasicAuth bool `toml:"skip_basic_auth"` + BasicAuthUsername string `toml:"basic_auth_username"` + BasicAuthPassword string `toml:"basic_auth_password"` + + SampleRate int `toml:"audio_sample_rate"` + ChannelCount int `toml:"audio_channel_count"` + + DumpFile string `toml:"dump_file"` + + LogDir string `toml:"log_dir"` + LogName string `toml:"log_name"` + LogDebug bool `toml:"log_debug"` + LogStdout bool `toml:"log_stdout"` + + TimeToWaitForOpusPacketMs int `toml:"time_to_wait_for_opus_packet_ms"` + + // Amazon Web Services + AwsCredentialFile string `toml:"aws_credential_file"` + AwsProfile string `toml:"aws_profile"` + AwsRegion string `toml:"aws_region"` + AwsEnablePartialResultsStabilization bool `toml:"aws_enable_partial_results_stabilization"` + AwsPartialResultsStability string `toml:"aws_partial_results_stability"` + AwsEnableChannelIdentification bool `toml:"aws_enable_channel_identification"` + + // Google Cloud Platform + GcpCredentialFile string `toml:"gcp_credential_file"` + GcpEnableSeparateRecognitionPerChannel bool `toml:"gcp_enable_separate_recognition_per_channel"` + GcpAlternativeLanguageCodes []string `toml:"gcp_alternative_language_codes"` + GcpMaxAlternatives int32 `toml:"gcp_max_alternatives"` + GcpProfanityFilter bool `toml:"gcp_profanity_filter"` + GcpEnableWordTimeOffsets bool `toml:"gcp_enable_word_time_offsets"` + GcpEnableWordConfidence bool `toml:"gcp_enable_word_confidence"` + GcpEnableAutomaticPunctuation bool `toml:"gcp_enable_automatic_punctuation"` + GcpEnableSpokenPunctuation bool `toml:"gcp_enable_spoken_punctuation"` + GcpEnableSpokenEmojis bool `toml:"gcp_enable_spoken_emojis"` + GcpModel string `toml:"gcp_model"` + GcpUseEnhanced bool `toml:"gcp_use_enhanced"` + GcpSingleUtterance bool `toml:"gcp_single_utterance"` + GcpInterimResults bool `toml:"gcp_interim_results"` +} + +func InitConfig(data []byte, config *Config) error { + if err := toml.Unmarshal(data, config); err != nil { + // パースに失敗した場合 Fatal で終了 + return err + } + + if config.TimeToWaitForOpusPacketMs == 0 { + config.TimeToWaitForOpusPacketMs = DefaultTimeToWaitForOpusPacketMs + } + + // TODO(v): 初期値 + return nil +} diff --git a/doc/AWS.md b/doc/AWS.md new file mode 100644 index 0000000..9e56891 --- /dev/null +++ b/doc/AWS.md @@ -0,0 +1,7 @@ +# Amazon Transcribe + +## 音声の解析結果が 2 つ返ってくる + +`config.toml` で `aws_enable_channel_identification` を `false` にし、 +`audio_channel_count` を 1 に設定してください。 + diff --git a/doc/DEV.md b/doc/DEV.md new file mode 100644 index 0000000..ccc5fba --- /dev/null +++ b/doc/DEV.md @@ -0,0 +1,29 @@ +# 開発者向け + +## セットアップ + +初回だけ make init と設定を cp する必要があります。 + +```console +$ make init +$ cp config.example.toml config.toml +``` + +## リリースビルド + +```console +$ make +``` + +bin 以下にバイナリが生成されます。 + +## ライブラリロード + +air をインストールして使ってください。 + +[cosmtrek/air: ☁️ Live reload for Go apps](https://github.com/cosmtrek/air) + +```console +$ air +``` + diff --git a/doc/GCP.md b/doc/GCP.md new file mode 100644 index 0000000..2396db0 --- /dev/null +++ b/doc/GCP.md @@ -0,0 +1,9 @@ +# Google Cloud Speech-to-Text + +## 5 分で接続が切れる + +Google Cloud Speech-to-Text のストリーミングリクエストの音声の長さの上限には 5 分の制限がありますのでご注意ください。 + +また、その他にも制限がありますので、詳細は下記をご確認ください。 + +https://cloud.google.com/speech-to-text/quotas?hl=ja \ No newline at end of file diff --git a/doc/USE.md b/doc/USE.md new file mode 100644 index 0000000..bbdc6b7 --- /dev/null +++ b/doc/USE.md @@ -0,0 +1,45 @@ +# 使ってみる + +## パッケージダウンロード + + + +## 設定ファイル + +サンプルをコピーしてください。 + +``` +$ cp config.example.toml config.toml +``` + + +## Amazon Transcribe を利用する + +-service で `aws` を指定することで AWS Transcribe が利用されます。 + +``` +$ ./suzu -C config.toml -service aws +``` + +AWS Transcribe を利用するに当たっての注意事項は [AWS.md](AWS.md) をご確認ください。 + +## Google Speech To Text を利用する + +-service で `gcp` を指定することで GCP Speech-to-Text が利用されます。 + +``` +$ ./suzu -C config.toml -service gcp +``` + +GCP Speech-to-Text を利用するに当たっての注意事項は [GCP.md](GCP.md) をご確認ください。 + +## デバッグ機能 + +### /test + +実際に音声解析サーバーにパケットを流しません。送られてきた音声のバイナリサイズをプッシュ通知で送り返します。 + +### /dump + +この URL を Sora の audio_streaming_url を指定すると、 +音声ストリミーングに流れてくる音声データを JSON 形式でダンプします。 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a931f31 --- /dev/null +++ b/go.mod @@ -0,0 +1,65 @@ +module github.com/shiguredo/suzu + +go 1.19 + +require ( + github.com/BurntSushi/toml v1.2.1 + github.com/aws/aws-sdk-go v1.44.167 + github.com/labstack/echo-contrib v0.13.0 + github.com/labstack/echo/v4 v4.9.1 + github.com/pion/randutil v0.1.0 + github.com/pion/rtp v1.7.13 + github.com/rs/zerolog v1.28.0 + github.com/shiguredo/lumberjack/v3 v3.0.0 + golang.org/x/net v0.4.0 + golang.org/x/sync v0.1.0 +) + +require ( + cloud.google.com/go/speech v1.9.0 + github.com/stretchr/testify v1.8.1 + go.uber.org/goleak v1.2.0 + google.golang.org/api v0.102.0 + google.golang.org/protobuf v1.28.1 +) + +require ( + cloud.google.com/go v0.105.0 // indirect + cloud.google.com/go/compute v1.12.1 // indirect + cloud.google.com/go/compute/metadata v0.2.1 // indirect + cloud.google.com/go/longrunning v0.1.1 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/gax-go/v2 v2.6.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/labstack/gommon v0.4.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.13.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect + github.com/rogpeppe/go-internal v1.8.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.1 // indirect + go.opencensus.io v0.23.0 // indirect + golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect + golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect + golang.org/x/sys v0.3.0 // indirect + golang.org/x/text v0.5.0 // indirect + golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect + google.golang.org/grpc v1.50.1 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..9f57388 --- /dev/null +++ b/go.sum @@ -0,0 +1,608 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y= +cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v1.12.1 h1:gKVJMEyqV5c/UnpzjjQbo3Rjvvqpr9B1DFSbJC4OXr0= +cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= +cloud.google.com/go/compute/metadata v0.2.1 h1:efOwf5ymceDhK6PKMnnrTHP4pppY5L22mle96M1yP48= +cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/longrunning v0.1.1 h1:y50CXG4j0+qvEukslYFBCrzaXX0qpFbBzc3PchSu/LE= +cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/speech v1.9.0 h1:yK0ocnFH4Wsf0cMdUyndJQ/hPv02oTJOxzi6AgpBy4s= +cloud.google.com/go/speech v1.9.0/go.mod h1:xQ0jTcmnRFFM2RfX/U+rk6FQNUF6DQlydUSyoooSpco= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/appleboy/gofight/v2 v2.1.2 h1:VOy3jow4vIK8BRQJoC/I9muxyYlJ2yb9ht2hZoS3rf4= +github.com/aws/aws-sdk-go v1.44.167 h1:kQmBhGdZkQLU7AiHShSkBJ15zr8agy0QeaxXduvyp2E= +github.com/aws/aws-sdk-go v1.44.167/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs= +github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.6.0 h1:SXk3ABtQYDT/OH8jAyvEOQ58mgawq5C4o/4/89qN2ZU= +github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/labstack/echo-contrib v0.13.0 h1:bzSG0SpuZZd7BmJLvsWtPfU23W0Enh3K0tok3aENVKA= +github.com/labstack/echo-contrib v0.13.0/go.mod h1:IF9+MJu22ADOZEHD+bAV67XMIO3vNXUy7Naz/ABPHEs= +github.com/labstack/echo/v4 v4.9.1 h1:GliPYSpzGKlyOhqIbG8nmHBo3i1saKWFOgh41AN3b+Y= +github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo= +github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09JkG9WeqChjprR5s9bBZ+OM= +github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= +github.com/pion/rtp v1.7.13 h1:qcHwlmtiI50t1XivvoawdCGTP4Uiypzfrsap+bijcoA= +github.com/pion/rtp v1.7.13/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= +github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= +github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/shiguredo/lumberjack/v3 v3.0.0 h1:IkhnjVTpg7Fl2fNAfsMn7R+No9SrnFdN5wEWBY2KOT8= +github.com/shiguredo/lumberjack/v3 v3.0.0/go.mod h1:zrQSStRcwpVudSkotZINDGYm8x03gnEQd7M+Y0OzPp0= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI= +golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= +golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.102.0 h1:JxJl2qQ85fRMPNvlZY/enexbxpCjLwGhZUtgfGeQ51I= +google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c h1:QgY/XxIAIeccR+Ca/rDdKubLIU9rcJ3xfy1DC/Wd2Oo= +google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= +google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/handler.go b/handler.go new file mode 100644 index 0000000..bc6d8e3 --- /dev/null +++ b/handler.go @@ -0,0 +1,281 @@ +package suzu + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "time" + + "github.com/labstack/echo/v4" + "github.com/pion/rtp/codecs" + zlog "github.com/rs/zerolog/log" +) + +// https://echo.labstack.com/cookbook/streaming-response/ +// TODO(v): http/2 の streaming を使ってレスポンスを戻す方法を調べる + +// https://github.com/herrberk/go-http2-streaming/blob/master/http2/server.go +// 受信時はくるくるループを回す +func (s *Server) createSpeechHandler(serviceType string, f func(context.Context, io.Reader, HandlerArgs) (*io.PipeReader, error)) echo.HandlerFunc { + return func(c echo.Context) error { + zlog.Debug().Msg("CONNECTING") + // http/2 じゃなかったらエラー + if c.Request().ProtoMajor != 2 { + zlog.Error().Msg("INVALID-HTTP-PROTOCOL") + return echo.NewHTTPError(http.StatusBadRequest) + } + + h := struct { + SoraChannelID string `header:"Sora-Channel-Id"` + // SoraSessionID string `header:"sora-session-id"` + // SoraClientID string `header:"sora-client-id"` + SoraConnectionID string `header:"sora-connection-id"` + // SoraAudioCodecType string `header:"sora-audio-codec-type"` + // SoraAudioSampleRate int64 `header:"sora-audio-sample-rate"` + SoraAudioStreamingLanguageCode string `header:"sora-audio-streaming-language-code"` + }{} + if err := (&echo.DefaultBinder{}).BindHeaders(c, &h); err != nil { + zlog.Error().Err(err).Msg("INVALID-HEADER") + return echo.NewHTTPError(http.StatusBadRequest) + } + defer func() { + zlog.Debug(). + Str("channel_id", h.SoraChannelID). + Str("connection_id", h.SoraConnectionID). + Msg("DISCONNECTED") + }() + + languageCode, err := GetLanguageCode(serviceType, h.SoraAudioStreamingLanguageCode, nil) + if err != nil { + zlog.Error().Err(err).Str("CHANNEL-ID", h.SoraChannelID).Str("CONNECTION-ID", h.SoraConnectionID).Send() + return echo.NewHTTPError(http.StatusInternalServerError) + } + + zlog.Debug(). + Str("channel_id", h.SoraChannelID). + Str("connection_id", h.SoraConnectionID). + Str("language_code", h.SoraAudioStreamingLanguageCode). + Msg("CONNECTED") + + c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSON) + c.Response().WriteHeader(http.StatusOK) + + ctx := c.Request().Context() + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + // TODO: ヘッダから取得する + sampleRate := uint32(s.config.SampleRate) + channelCount := uint16(s.config.ChannelCount) + + args := NewHandlerArgs(*s.config, sampleRate, channelCount, h.SoraChannelID, h.SoraConnectionID, languageCode) + + reader, err := f(ctx, c.Request().Body, args) + if err != nil { + zlog.Error().Err(err).Str("CHANNEL-ID", h.SoraChannelID).Str("CONNECTION-ID", h.SoraConnectionID).Send() + // TODO: エラー内容で status code を変更する + return echo.NewHTTPError(http.StatusInternalServerError) + } + defer reader.Close() + + for { + buf := make([]byte, FrameSize) + n, err := reader.Read(buf) + if err != nil { + if errors.Is(err, io.EOF) { + break + } else if err.Error() == "failed to read audio, client disconnected" { + // TODO: エラーレベルを見直す + zlog.Error().Err(err).Str("CHANNEL-ID", h.SoraChannelID).Str("CONNECTION-ID", h.SoraConnectionID).Send() + return echo.NewHTTPError(499) + } + zlog.Error().Err(err).Str("CHANNEL-ID", h.SoraChannelID).Str("CONNECTION-ID", h.SoraConnectionID).Send() + return echo.NewHTTPError(http.StatusInternalServerError) + } + + if n > 0 { + if _, err := c.Response().Write(buf[:n]); err != nil { + zlog.Error().Err(err).Str("CHANNEL-ID", h.SoraChannelID).Str("CONNECTION-ID", h.SoraConnectionID).Send() + return echo.NewHTTPError(http.StatusInternalServerError) + } + c.Response().Flush() + } + } + + return c.NoContent(http.StatusOK) + } +} + +type HandlerArgs struct { + Config Config + SoraChannelID string + SoraConnectionID string + SampleRate uint32 + ChannelCount uint16 + LanguageCode string +} + +func NewHandlerArgs(config Config, sampleRate uint32, channelCount uint16, soraChannelID, soraConnectionID, languageCode string) HandlerArgs { + return HandlerArgs{ + Config: config, + SampleRate: sampleRate, + ChannelCount: channelCount, + SoraChannelID: soraChannelID, + SoraConnectionID: soraConnectionID, + LanguageCode: languageCode, + } +} + +func opus2ogg(ctx context.Context, opusReader io.Reader, oggWriter io.Writer, sampleRate uint32, channelCount uint16, c Config) error { + o, err := NewWith(oggWriter, sampleRate, channelCount) + if err != nil { + if w, ok := oggWriter.(*io.PipeWriter); ok { + w.CloseWithError(err) + } + return err + } + defer o.Close() + + if err := o.writeHeaders(); err != nil { + if w, ok := oggWriter.(*io.PipeWriter); ok { + w.CloseWithError(err) + } + return err + } + + for { + buf := make([]byte, FrameSize) + n, err := opusReader.Read(buf) + if err != nil { + if w, ok := oggWriter.(*io.PipeWriter); ok { + w.CloseWithError(err) + } + return err + } + if n > 0 { + opus := codecs.OpusPacket{} + _, err := opus.Unmarshal(buf[:n]) + if err != nil { + if w, ok := oggWriter.(*io.PipeWriter); ok { + w.CloseWithError(err) + } + return err + } + + if err := o.Write(&opus); err != nil { + if w, ok := oggWriter.(*io.PipeWriter); ok { + w.CloseWithError(err) + } + return err + } + } + } +} + +type Response struct { + ChannelID *string `json:"channel_id"` + Message string `json:"message"` + Error error `json:"error,omitempty"` +} + +func readerWithSilentPacketFromOpusReader(d time.Duration, opusReader io.Reader) (io.Reader, error) { + type reqeust struct { + Payload []byte + Error error + } + + r, w := io.Pipe() + ch := make(chan reqeust) + + go func() { + for { + buf := make([]byte, FrameSize) + n, err := opusReader.Read(buf) + if err != nil { + ch <- reqeust{ + Error: err, + } + return + } + + if n > 0 { + ch <- reqeust{ + Payload: buf[:n], + } + } + } + }() + + timer := time.NewTimer(d) + go func() { + for { + select { + case <-timer.C: + if _, err := w.Write(silentPacket()); err != nil { + w.CloseWithError(err) + return + } + case req := <-ch: + if err := req.Error; err != nil { + w.CloseWithError(err) + if !timer.Stop() { + <-timer.C + } + return + } + if _, err := w.Write(req.Payload); err != nil { + w.CloseWithError(err) + if !timer.Stop() { + <-timer.C + } + return + } + } + timer.Reset(d) + } + }() + + return r, nil +} + +func silentPacket() []byte { + return []byte{252, 255, 254} +} + +type serviceHandler func(ctx context.Context, conn io.Reader, args HandlerArgs) (*io.PipeReader, error) + +type serviceHandlers struct { + Handlers map[string]serviceHandler +} + +func NewServiceHandlers() serviceHandlers { + return serviceHandlers{ + Handlers: make(map[string]serviceHandler), + } +} + +var ServiceHandlers = NewServiceHandlers() + +func (sh *serviceHandlers) registerHandler(name string, handler serviceHandler) { + sh.Handlers[name] = handler +} + +func (sh *serviceHandlers) getServiceHandler(name string) (serviceHandler, error) { + h, ok := sh.Handlers[name] + if !ok { + return nil, fmt.Errorf("UNREGISTERED-SERVICE: %s", name) + } + + return h, nil +} + +func (sh *serviceHandlers) GetNames() []string { + var names []string + for name := range sh.Handlers { + names = append(names, name) + } + + return names +} diff --git a/handler_test.go b/handler_test.go new file mode 100644 index 0000000..39225a4 --- /dev/null +++ b/handler_test.go @@ -0,0 +1,420 @@ +package suzu + +import ( + "bufio" + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/http/httptest" + "os" + "testing" + "testing/iotest" + "time" + + "github.com/labstack/echo/v4" + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" + "github.com/stretchr/testify/assert" + + "go.uber.org/goleak" +) + +var ( + config = Config{ + Debug: true, + ListenAddr: "127.0.0.1", + ListenPort: 48080, + SkipBasicAuth: true, + LogDebug: true, + LogStdout: true, + DumpFile: "./test-dump.jsonl", + TimeToWaitForOpusPacketMs: 500, + } +) + +func readDumpFile(t *testing.T, filename string, d time.Duration) *io.PipeReader { + t.Helper() + + f, err := os.Open(filename) + if err != nil { + t.Fatal(err) + } + + scanner := bufio.NewScanner(f) + + r, w := io.Pipe() + + go func() { + defer w.Close() + defer f.Close() + + for scanner.Scan() { + b := scanner.Bytes() + s := struct { + Payload []byte `json:"payload"` + }{} + if err := json.Unmarshal(b, &s); err != nil { + t.Error(err.Error()) + return + } + + if _, err := w.Write(s.Payload); err != nil { + // 停止条件を r.Close() にしているため、io: read/write on closed pipe エラーは出力される + t.Log(err.Error()) + return + } + + if d > 0 { + time.Sleep(d) + } + } + + if err := scanner.Err(); err != nil { + t.Error(err.Error()) + return + } + }() + + return r +} + +func TestSpeechHandler(t *testing.T) { + handler := AmazonTranscribeHandler + path := "/speech" + serviceType := "aws" + if testing.Short() { + handler = TestHandler + path = "/test" + } + s, err := NewServer(&config, "aws") + if err != nil { + t.Fatal(err) + } + + t.Run("success", func(t *testing.T) { + //opt := goleak.IgnoreCurrent() + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + r := readDumpFile(t, "testdata/dump.jsonl", 0) + defer r.Close() + + e := echo.New() + req := httptest.NewRequest("POST", path, r) + req.Header.Set("sora-audio-streaming-language-code", "ja-JP") + req.Proto = "HTTP/2.0" + req.ProtoMajor = 2 + req.ProtoMinor = 0 + rec := httptest.NewRecorder() + c := e.NewContext(req, rec) + + h := s.createSpeechHandler(serviceType, handler) + err := h(c) + if assert.NoError(t, err) { + assert.Equal(t, http.StatusOK, rec.Code) + + delim := []byte("\n")[0] + for { + line, err := rec.Body.ReadBytes(delim) + if err != nil { + if !assert.ErrorIs(t, err, io.EOF) { + t.Logf("READ-ERROR: %v\n", err) + } + break + } + response := Response{} + if err := json.Unmarshal(line, &response); err != nil { + t.Error(err) + } + + assert.NotEmpty(t, response.ChannelID) + assert.NotEmpty(t, response.Message) + } + } + + }) + + t.Run("unexpected http proto version", func(t *testing.T) { + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + logger := log.Logger + defer func() { + log.Logger = logger + }() + + pr, pw, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + log.Logger = zerolog.New(pw).With().Caller().Timestamp().Logger() + + r := readDumpFile(t, "testdata/dump.jsonl", 0) + defer r.Close() + + e := echo.New() + req := httptest.NewRequest("POST", path, r) + req.Header.Set("sora-audio-streaming-language-code", "ja-JP") + req.Proto = "HTTP/1.1" + req.ProtoMajor = 1 + req.ProtoMinor = 1 + rec := httptest.NewRecorder() + c := e.NewContext(req, rec) + + h := s.createSpeechHandler(serviceType, handler) + err = h(c) + if assert.Error(t, err) { + assert.Equal(t, http.StatusBadRequest, err.(*echo.HTTPError).Code) + } + + pw.Close() + + var buf bytes.Buffer + n, err := buf.ReadFrom(pr) + if err != nil { + t.Fatal(err) + } + assert.Contains(t, buf.String()[:n], "INVALID-HTTP-PROTOCOL") + }) + + t.Run("missing sora-audio-streaming-language-code header", func(t *testing.T) { + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + logger := log.Logger + defer func() { + log.Logger = logger + }() + + pr, pw, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + log.Logger = zerolog.New(pw).With().Caller().Timestamp().Logger() + + r := readDumpFile(t, "testdata/dump.jsonl", 0) + defer r.Close() + + e := echo.New() + req := httptest.NewRequest("POST", path, r) + req.Proto = "HTTP/2.0" + req.ProtoMajor = 2 + req.ProtoMinor = 0 + rec := httptest.NewRecorder() + c := e.NewContext(req, rec) + + h := s.createSpeechHandler(serviceType, handler) + err = h(c) + if assert.Error(t, err) { + assert.Equal(t, http.StatusInternalServerError, err.(*echo.HTTPError).Code) + } + + pw.Close() + + var buf bytes.Buffer + n, err := buf.ReadFrom(pr) + if err != nil { + t.Fatal(err) + } + assert.Contains(t, buf.String()[:n], "MISSING-SORA-AUDIO-STREAMING-LANGUAGE-CODE") + }) + + t.Run("unsupported language code", func(t *testing.T) { + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + logger := log.Logger + defer func() { + log.Logger = logger + }() + + pr, pw, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + log.Logger = zerolog.New(pw).With().Caller().Timestamp().Logger() + + r := readDumpFile(t, "testdata/dump.jsonl", 0) + defer r.Close() + + e := echo.New() + req := httptest.NewRequest("POST", path, r) + req.Header.Set("sora-audio-streaming-language-code", "en-JP") + req.Proto = "HTTP/2.0" + req.ProtoMajor = 2 + req.ProtoMinor = 0 + rec := httptest.NewRecorder() + c := e.NewContext(req, rec) + + h := s.createSpeechHandler(serviceType, handler) + err = h(c) + if assert.Error(t, err) { + assert.Equal(t, http.StatusInternalServerError, err.(*echo.HTTPError).Code) + } + + pw.Close() + + var buf bytes.Buffer + n, err := buf.ReadFrom(pr) + if err != nil { + t.Fatal(err) + } + assert.Contains(t, buf.String()[:n], "UNSUPPORTED-LANGUAGE-CODE: aws, en-JP") + }) + + t.Run("packet read error", func(t *testing.T) { + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + logger := log.Logger + defer func() { + log.Logger = logger + }() + + pr, pw, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + log.Logger = zerolog.New(pw).With().Caller().Timestamp().Logger() + + r := iotest.ErrReader(errors.New("packet read error")) + + e := echo.New() + req := httptest.NewRequest("POST", path, r) + req.Header.Set("sora-audio-streaming-language-code", "ja-JP") + req.Proto = "HTTP/2.0" + req.ProtoMajor = 2 + req.ProtoMinor = 0 + rec := httptest.NewRecorder() + c := e.NewContext(req, rec) + + h := s.createSpeechHandler(serviceType, handler) + err = h(c) + if assert.Error(t, err) { + assert.Equal(t, http.StatusInternalServerError, err.(*echo.HTTPError).Code) + } + + pw.Close() + + var buf bytes.Buffer + n, err := buf.ReadFrom(pr) + if err != nil { + t.Fatal(err) + } + assert.Contains(t, buf.String()[:n], "packet read error") + }) + + t.Run("silent packet", func(t *testing.T) { + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + timeout := config.TimeToWaitForOpusPacketMs + defer func() { + config.TimeToWaitForOpusPacketMs = timeout + }() + + config.TimeToWaitForOpusPacketMs = 100 + + s, err := NewServer(&config, "aws") + if err != nil { + t.Fatal(err) + } + + r := readDumpFile(t, "testdata/dump.jsonl", 150*time.Millisecond) + defer r.Close() + + e := echo.New() + req := httptest.NewRequest("POST", path, r) + req.Header.Set("sora-audio-streaming-language-code", "ja-JP") + req.Proto = "HTTP/2.0" + req.ProtoMajor = 2 + req.ProtoMinor = 0 + ctx := context.Background() + ctx, cancel := context.WithTimeout(ctx, 60*time.Second) + defer cancel() + req2 := req.WithContext(ctx) + rec := httptest.NewRecorder() + c := e.NewContext(req2, rec) + + h := s.createSpeechHandler(serviceType, handler) + err = h(c) + if assert.NoError(t, err) { + assert.Equal(t, http.StatusOK, rec.Code) + + delim := []byte("\n")[0] + for { + line, err := rec.Body.ReadBytes(delim) + if err != nil { + if !assert.ErrorIs(t, err, io.EOF) { + t.Logf("READ-ERROR: %v\n", err) + } + break + } + response := Response{} + if err := json.Unmarshal(line, &response); err != nil { + t.Error(err) + } + + assert.NotEmpty(t, response.ChannelID) + assert.NotEmpty(t, response.Message) + } + } + + }) + +} + +func TestHealthcheckHandler(t *testing.T) { + type request struct { + Proto string + ProtoMajor int + ProtoMinor int + } + type expect struct { + StatusCode int + Body string + } + + s, err := NewServer(&config, "aws") + if err != nil { + t.Fatal(err) + } + body := fmt.Sprintf(`{"revision":"%s"}`, s.config.Revision) + + testCaces := []struct { + Name string + Request request + Expect expect + }{ + {"HTTP/2", request{"HTTP/2", 2, 0}, expect{http.StatusOK, body}}, + {"HTTP/1.1", request{"HTTP/1.1", 1, 1}, expect{http.StatusOK, body}}, + } + + for _, tc := range testCaces { + t.Run(tc.Name, func(t *testing.T) { + opt := goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") + defer goleak.VerifyNone(t, opt) + + e := echo.New() + req := httptest.NewRequest("GET", "/.ok", nil) + req.Proto = tc.Request.Proto + req.ProtoMajor = tc.Request.ProtoMajor + req.ProtoMinor = tc.Request.ProtoMinor + rec := httptest.NewRecorder() + c := e.NewContext(req, rec) + + err := s.healthcheckHandler(c) + if assert.NoError(t, err) { + assert.Equal(t, tc.Expect.StatusCode, rec.Code) + resp := rec.Result() + body, _ := io.ReadAll(resp.Body) + assert.JSONEq(t, tc.Expect.Body, string(body)) + } + + }) + } +} diff --git a/healthcheck_handler.go b/healthcheck_handler.go new file mode 100644 index 0000000..ca056c3 --- /dev/null +++ b/healthcheck_handler.go @@ -0,0 +1,13 @@ +package suzu + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +func (s *Server) healthcheckHandler(c echo.Context) error { + return c.JSON(http.StatusOK, map[string]interface{}{ + "revision": s.config.Revision, + }) +} diff --git a/languages.go b/languages.go new file mode 100644 index 0000000..dd20eed --- /dev/null +++ b/languages.go @@ -0,0 +1,37 @@ +package suzu + +import ( + "fmt" + + "github.com/aws/aws-sdk-go/service/transcribestreamingservice" +) + +var ( + ErrMissinuAudioStreamingLanguageCode = fmt.Errorf("MISSING-SORA-AUDIO-STREAMING-LANGUAGE-CODE") + ErrUnsupportedLanguageCode = fmt.Errorf("UNSUPPORTED-LANGUAGE-CODE") + ErrUnsupportedService = fmt.Errorf("UNSUPPORTED-SERVICE") +) + +func GetLanguageCode(serviceType, lang string, f func(string) (string, error)) (string, error) { + if lang == "" { + return "", ErrMissinuAudioStreamingLanguageCode + } + + if f != nil { + return f(lang) + } + + if serviceType == "aws" { + for _, languageCode := range transcribestreamingservice.LanguageCode_Values() { + if languageCode == lang { + return languageCode, nil + } + } + } else if serviceType == "gcp" { + return lang, nil + } else { + return "", fmt.Errorf("%w: %s", ErrUnsupportedService, serviceType) + } + + return "", fmt.Errorf("%w: %s, %s", ErrUnsupportedLanguageCode, serviceType, lang) +} diff --git a/logging.go b/logging.go new file mode 100644 index 0000000..ac85a14 --- /dev/null +++ b/logging.go @@ -0,0 +1,78 @@ +package suzu + +import ( + "fmt" + "io" + "os" + "strings" + "time" + + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" + "github.com/shiguredo/lumberjack/v3" +) + +var ( + // megabytes + logRotateMaxSize = 200 + logRotateMaxBackups = 7 + // days + logRotateMaxAge = 30 +) + +// InitLogger ロガーを初期化する +func InitLogger(config Config) error { + + if f, err := os.Stat(config.LogDir); os.IsNotExist(err) || !f.IsDir() { + return err + } + + logPath := fmt.Sprintf("%s/%s", config.LogDir, config.LogName) + + writer := &lumberjack.Logger{ + Filename: logPath, + MaxSize: logRotateMaxSize, + MaxBackups: logRotateMaxBackups, + MaxAge: logRotateMaxAge, + Compress: false, + } + + // https://github.com/rs/zerolog/issues/77 + zerolog.TimestampFunc = func() time.Time { + return time.Now().UTC() + } + + zerolog.TimeFieldFormat = time.RFC3339Nano + + var writers io.Writer + // lumberjack を登録 + writers = zerolog.MultiLevelWriter(writer) + + if config.Debug { + zerolog.SetGlobalLevel(zerolog.DebugLevel) + } else { + zerolog.SetGlobalLevel(zerolog.InfoLevel) + } + // log_stdout: true の時はコンソールにもだす + if config.LogStdout { + consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: "2006-01-02 15:04:05.000000Z"} + format(&consoleWriter) + writers = zerolog.MultiLevelWriter(writers, consoleWriter) + } + + log.Logger = zerolog.New(writers).With().Caller().Timestamp().Logger() + + return nil +} + +func format(w *zerolog.ConsoleWriter) { + w.FormatLevel = func(i interface{}) string { + return strings.ToUpper(fmt.Sprintf("[%s]", i)) + } + w.FormatFieldName = func(i interface{}) string { + return fmt.Sprintf("%s=", i) + } + w.FormatFieldValue = func(i interface{}) string { + return fmt.Sprintf("%s", i) + } +} diff --git a/oggwriter.go b/oggwriter.go new file mode 100644 index 0000000..7698d61 --- /dev/null +++ b/oggwriter.go @@ -0,0 +1,262 @@ +package suzu + +import ( + "encoding/binary" + "errors" + "io" + "os" + + "github.com/pion/randutil" + "github.com/pion/rtp" + "github.com/pion/rtp/codecs" +) + +const ( + pageHeaderTypeContinuationOfStream = 0x00 + pageHeaderTypeBeginningOfStream = 0x02 + pageHeaderTypeEndOfStream = 0x04 + defaultPreSkip = 3840 // 3840 recommended in the RFC + idPageSignature = "OpusHead" + commentPageSignature = "OpusTags" + pageHeaderSignature = "OggS" + vendorName = "pion" +) + +var ( + errFileNotOpened = errors.New("file not opened") + errInvalidNilPacket = errors.New("invalid nil packet") +) + +// OggWriter is used to take RTP packets and write them to an OGG on disk +type OggWriter struct { + stream io.Writer + fd *os.File + sampleRate uint32 + channelCount uint16 + serial uint32 + pageIndex uint32 + checksumTable *[256]uint32 + previousGranulePosition uint64 + previousTimestamp uint32 + lastPayloadSize int +} + +// New builds a new OGG Opus writer +func New(fileName string, sampleRate uint32, channelCount uint16) (*OggWriter, error) { + f, err := os.Create(fileName) //nolint:gosec + if err != nil { + return nil, err + } + writer, err := NewWith(f, sampleRate, channelCount) + if err != nil { + return nil, f.Close() + } + writer.fd = f + return writer, nil +} + +// NewWith initialize a new OGG Opus writer with an io.Writer output +func NewWith(out io.Writer, sampleRate uint32, channelCount uint16) (*OggWriter, error) { + if out == nil { + return nil, errFileNotOpened + } + + writer := &OggWriter{ + stream: out, + sampleRate: sampleRate, + channelCount: channelCount, + serial: randutil.NewMathRandomGenerator().Uint32(), + checksumTable: generateChecksumTable(), + + // Timestamp and Granule MUST start from 1 + // Only headers can have 0 values + previousTimestamp: 1, + previousGranulePosition: 1, + } + + return writer, nil +} + +/* + ref: https://tools.ietf.org/html/rfc7845.html + https://git.xiph.org/?p=opus-tools.git;a=blob;f=src/opus_header.c#l219 + Page 0 Pages 1 ... n Pages (n+1) ... + +------------+ +---+ +---+ ... +---+ +-----------+ +---------+ +-- + | | | | | | | | | | | | | + |+----------+| |+-----------------+| |+-------------------+ +----- + |||ID Header|| || Comment Header || ||Audio Data Packet 1| | ... + |+----------+| |+-----------------+| |+-------------------+ +----- + | | | | | | | | | | | | | + +------------+ +---+ +---+ ... +---+ +-----------+ +---------+ +-- + ^ ^ ^ + | | | + | | Mandatory Page Break + | | + | ID header is contained on a single page + | + 'Beginning Of Stream' + Figure 1: Example Packet Organization for a Logical Ogg Opus Stream +*/ + +func (i *OggWriter) writeHeaders() error { + // ID Header + oggIDHeader := make([]byte, 19) + + copy(oggIDHeader[0:], idPageSignature) // Magic Signature 'OpusHead' + oggIDHeader[8] = 1 // Version + oggIDHeader[9] = uint8(i.channelCount) // Channel count + binary.LittleEndian.PutUint16(oggIDHeader[10:], defaultPreSkip) // pre-skip + binary.LittleEndian.PutUint32(oggIDHeader[12:], i.sampleRate) // original sample rate, any valid sample e.g 48000 + binary.LittleEndian.PutUint16(oggIDHeader[16:], 0) // output gain + oggIDHeader[18] = 0 // channel map 0 = one stream: mono or stereo + + // Reference: https://tools.ietf.org/html/rfc7845.html#page-6 + // RFC specifies that the ID Header page should have a granule position of 0 and a Header Type set to 2 (StartOfStream) + data := i.createPage(oggIDHeader, pageHeaderTypeBeginningOfStream, 0, i.pageIndex) + if err := i.writeToStream(data); err != nil { + return err + } + i.pageIndex++ + + // Comment Header + oggCommentHeader := make([]byte, (8 + len(vendorName) + 4 + 4)) + copy(oggCommentHeader[0:], commentPageSignature) // Magic Signature 'OpusTags' + binary.LittleEndian.PutUint32(oggCommentHeader[8:], uint32(len(vendorName))) // Vendor Length + copy(oggCommentHeader[12:], vendorName) // Vendor name 'pion' + binary.LittleEndian.PutUint32(oggCommentHeader[16:], 0) // User Comment List Length + + // RFC specifies that the page where the CommentHeader completes should have a granule position of 0 + data = i.createPage(oggCommentHeader, pageHeaderTypeContinuationOfStream, 0, i.pageIndex) + if err := i.writeToStream(data); err != nil { + return err + } + i.pageIndex++ + + return nil +} + +const ( + pageHeaderSize = 27 +) + +func (i *OggWriter) createPage(payload []uint8, headerType uint8, granulePos uint64, pageIndex uint32) []byte { + i.lastPayloadSize = len(payload) + page := make([]byte, pageHeaderSize+1+i.lastPayloadSize) + + copy(page[0:], pageHeaderSignature) // page headers starts with 'OggS' + page[4] = 0 // Version + page[5] = headerType // 1 = continuation, 2 = beginning of stream, 4 = end of stream + binary.LittleEndian.PutUint64(page[6:], granulePos) // granule position + binary.LittleEndian.PutUint32(page[14:], i.serial) // Bitstream serial number + binary.LittleEndian.PutUint32(page[18:], pageIndex) // Page sequence number + page[26] = 1 // Number of segments in page, giving always 1 segment + page[27] = uint8(i.lastPayloadSize) // Segment Table inserting at 27th position since page header length is 27 + copy(page[28:], payload) // inserting at 28th since Segment Table(1) + header length(27) + + var checksum uint32 + for index := range page { + checksum = (checksum << 8) ^ i.checksumTable[byte(checksum>>24)^page[index]] + } + binary.LittleEndian.PutUint32(page[22:], checksum) // Checksum - generating for page data and inserting at 22th position into 32 bits + + return page +} + +// WriteRTP adds a new packet and writes the appropriate headers for it +func (i *OggWriter) WriteRTP(packet *rtp.Packet) error { + if packet == nil { + return errInvalidNilPacket + } + if len(packet.Payload) == 0 { + return nil + } + + opusPacket := codecs.OpusPacket{} + if _, err := opusPacket.Unmarshal(packet.Payload); err != nil { + // Only handle Opus packets + return err + } + + payload := opusPacket.Payload[0:] + + // Should be equivalent to sampleRate * duration + if i.previousTimestamp != 1 { + increment := packet.Timestamp - i.previousTimestamp + i.previousGranulePosition += uint64(increment) + } else { + // TODO: 取得・計算したサンプル数を設定する + i.previousGranulePosition = 960 + } + i.previousTimestamp = packet.Timestamp + + data := i.createPage(payload, pageHeaderTypeContinuationOfStream, i.previousGranulePosition, i.pageIndex) + i.pageIndex++ + return i.writeToStream(data) +} + +// Close stops the recording +func (i *OggWriter) Close() error { + defer func() { + i.fd = nil + i.stream = nil + }() + + // Returns no error has it may be convenient to call + // Close() multiple times + if i.fd == nil { + // Close stream if we are operating on a stream + if closer, ok := i.stream.(io.Closer); ok { + return closer.Close() + } + return nil + } + + // Seek back one page, we need to update the header and generate new CRC + pageOffset, err := i.fd.Seek(-1*int64(i.lastPayloadSize+pageHeaderSize+1), 2) + if err != nil { + return err + } + + payload := make([]byte, i.lastPayloadSize) + if _, err := i.fd.ReadAt(payload, pageOffset+pageHeaderSize+1); err != nil { + return err + } + + data := i.createPage(payload, pageHeaderTypeEndOfStream, i.previousGranulePosition, i.pageIndex-1) + if err := i.writeToStream(data); err != nil { + return err + } + + // Update the last page if we are operating on files + // to mark it as the EOS + return i.fd.Close() +} + +// Wraps writing to the stream and maintains state +// so we can set values for EOS +func (i *OggWriter) writeToStream(p []byte) error { + if i.stream == nil { + return errFileNotOpened + } + + _, err := i.stream.Write(p) + return err +} + +func generateChecksumTable() *[256]uint32 { + var table [256]uint32 + const poly = 0x04c11db7 + + for i := range table { + r := uint32(i) << 24 + for j := 0; j < 8; j++ { + if (r & 0x80000000) != 0 { + r = (r << 1) ^ poly + } else { + r <<= 1 + } + table[i] = (r & 0xffffffff) + } + } + return &table +} diff --git a/oggwriter.go.patch b/oggwriter.go.patch new file mode 100644 index 0000000..21ab89e --- /dev/null +++ b/oggwriter.go.patch @@ -0,0 +1,69 @@ +--- oggwriter.go.org 2022-01-21 17:05:42.000000000 +0900 ++++ oggwriter.go 2022-01-25 12:25:33.000000000 +0900 +@@ -1,5 +1,4 @@ +-// Package oggwriter implements OGG media container writer +-package oggwriter ++package suzu + + import ( + "encoding/binary" +@@ -20,6 +19,7 @@ + idPageSignature = "OpusHead" + commentPageSignature = "OpusTags" + pageHeaderSignature = "OggS" ++ vendorName = "pion" + ) + + var ( +@@ -73,9 +73,6 @@ + previousTimestamp: 1, + previousGranulePosition: 1, + } +- if err := writer.writeHeaders(); err != nil { +- return nil, err +- } + + return writer, nil + } +@@ -83,7 +80,6 @@ + /* + ref: https://tools.ietf.org/html/rfc7845.html + https://git.xiph.org/?p=opus-tools.git;a=blob;f=src/opus_header.c#l219 +- + Page 0 Pages 1 ... n Pages (n+1) ... + +------------+ +---+ +---+ ... +---+ +-----------+ +---------+ +-- + | | | | | | | | | | | | | +@@ -99,7 +95,6 @@ + | ID header is contained on a single page + | + 'Beginning Of Stream' +- + Figure 1: Example Packet Organization for a Logical Ogg Opus Stream + */ + +@@ -124,11 +119,11 @@ + i.pageIndex++ + + // Comment Header +- oggCommentHeader := make([]byte, 21) +- copy(oggCommentHeader[0:], commentPageSignature) // Magic Signature 'OpusTags' +- binary.LittleEndian.PutUint32(oggCommentHeader[8:], 5) // Vendor Length +- copy(oggCommentHeader[12:], "pion") // Vendor name 'pion' +- binary.LittleEndian.PutUint32(oggCommentHeader[17:], 0) // User Comment List Length ++ oggCommentHeader := make([]byte, (8 + len(vendorName) + 4 + 4)) ++ copy(oggCommentHeader[0:], commentPageSignature) // Magic Signature 'OpusTags' ++ binary.LittleEndian.PutUint32(oggCommentHeader[8:], uint32(len(vendorName))) // Vendor Length ++ copy(oggCommentHeader[12:], vendorName) // Vendor name 'pion' ++ binary.LittleEndian.PutUint32(oggCommentHeader[16:], 0) // User Comment List Length + + // RFC specifies that the page where the CommentHeader completes should have a granule position of 0 + data = i.createPage(oggCommentHeader, pageHeaderTypeContinuationOfStream, 0, i.pageIndex) +@@ -188,6 +183,9 @@ + if i.previousTimestamp != 1 { + increment := packet.Timestamp - i.previousTimestamp + i.previousGranulePosition += uint64(increment) ++ } else { ++ // TODO: 取得・計算したサンプル数を設定する ++ i.previousGranulePosition = 960 + } + i.previousTimestamp = packet.Timestamp diff --git a/oggwriter_ext.go b/oggwriter_ext.go new file mode 100644 index 0000000..784000f --- /dev/null +++ b/oggwriter_ext.go @@ -0,0 +1,64 @@ +package suzu + +import "github.com/pion/rtp/codecs" + +func (i *OggWriter) Write(opusPacket *codecs.OpusPacket) error { + payload := opusPacket.Payload[0:] + toc := payload[0] + config := (toc & 0xf8) >> 3 + c := toc & 0x03 + + var count uint64 + switch c { + case 0: + count = 1 + case 1, 2: + count = 2 + case 3: + m := payload[1] & 0x3f + count = uint64(m) + } + + // TODO: 値の決定に他の要素が必要ないか確認する + granulePosition := GranulePosition(config) + + i.previousGranulePosition += count * granulePosition + + data := i.createPage(payload, pageHeaderTypeContinuationOfStream, i.previousGranulePosition, i.pageIndex) + i.pageIndex++ + return i.writeToStream(data) +} + +// config | frame size | PCM samples +// ---------------+------------+------------ +// 16, 20, 24, 28 | 2.5 ms | 120 +// 17, 21, 25, 29 | 5 ms | 240 +// 0, 4, 8 | 10 ms | 480 +// 12, 14 | 10 ms | 480 +// 18, 22, 26, 30 | 10 ms | 480 +// 1, 5, 9 | 20 ms | 960 +// 13, 15 | 20 ms | 960 +// 19, 23, 27, 31 | 20 ms | 960 +// 2, 6, 10 | 40 ms | 1920 +// 3, 7, 11 | 60 ms | 2880 + +func GranulePosition(config byte) uint64 { + // TODO: 値の決定に他の要素が必要ないか確認する + var granulePosition uint64 + switch config { + case 16, 20, 24, 28: + granulePosition = 120 + case 17, 21, 25, 29: + granulePosition = 240 + case 0, 4, 8, 12, 14, 18, 22, 26, 30: + granulePosition = 480 + case 1, 5, 9, 13, 15, 19, 23, 27, 31: + granulePosition = 960 + case 2, 6, 10: + granulePosition = 1920 + case 3, 7, 11: + granulePosition = 2880 + } + + return granulePosition +} diff --git a/packet_dump_handler.go b/packet_dump_handler.go new file mode 100644 index 0000000..9be57a3 --- /dev/null +++ b/packet_dump_handler.go @@ -0,0 +1,66 @@ +package suzu + +import ( + "context" + "encoding/json" + "io" + "os" + "time" +) + +type dump struct { + Timestamp int64 `json:"timestamp"` + ChannelID string `json:"channel_id"` + ConnectionID string `json:"connection_id"` + LanguageCode string `json:"language_code"` + SampleRate uint32 `json:"sample_rate"` + ChannelCount uint16 `json:"channel_count"` + Payload []byte `json:"payload"` +} + +func PacketDumpHandler(ctx context.Context, body io.Reader, args HandlerArgs) (*io.PipeReader, error) { + c := args.Config + filename := c.DumpFile + channelID := args.SoraChannelID + connectionID := args.SoraConnectionID + + r, w := io.Pipe() + + go func() { + f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + w.CloseWithError(err) + return + } + defer f.Close() + defer w.Close() + + mv := io.MultiWriter(f, w) + encoder := json.NewEncoder(mv) + + for { + buf := make([]byte, FrameSize) + n, err := r.Read(buf) + if err != nil { + return + } + if n > 0 { + dump := dump{ + Timestamp: time.Now().UnixMilli(), + ChannelID: channelID, + ConnectionID: connectionID, + LanguageCode: args.LanguageCode, + SampleRate: args.SampleRate, + ChannelCount: args.ChannelCount, + Payload: buf[:n], + } + if err := encoder.Encode(dump); err != nil { + w.CloseWithError(err) + return + } + } + } + }() + + return r, nil +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..f0711cd --- /dev/null +++ b/renovate.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ], + "dependencyDashboard": false, + "timezone": "Asia/Tokyo", + "schedule": [ + "before 10am on Monday" + ], + "packageRules": [ + { + "matchUpdateTypes": ["minor", "patch", "pin", "digest"], + "platformAutomerge": true, + "automerge": true + } + ] +} diff --git a/server.go b/server.go new file mode 100644 index 0000000..43a80f7 --- /dev/null +++ b/server.go @@ -0,0 +1,198 @@ +package suzu + +import ( + "context" + "crypto/tls" + "crypto/x509" + "fmt" + "net" + "net/http" + "os" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/labstack/echo-contrib/prometheus" + "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" + zlog "github.com/rs/zerolog/log" + "golang.org/x/net/http2" +) + +type Server struct { + config *Config + echo *echo.Echo + echoExporter *echo.Echo + + http.Server +} + +func NewServer(c *Config, service string) (*Server, error) { + h2s := &http2.Server{ + MaxConcurrentStreams: c.HTTP2MaxConcurrentStreams, + MaxReadFrameSize: c.HTTP2MaxReadFrameSize, + IdleTimeout: time.Duration(c.HTTP2IdleTimeout) * time.Second, + } + + e := echo.New() + + s := &Server{ + config: c, + Server: http.Server{ + Addr: net.JoinHostPort("", strconv.Itoa(c.ListenPort)), + Handler: e, + }, + } + + // クライアント認証をするかどうかのチェック + if c.HTTP2VerifyCacertPath != "" { + clientCAPath := c.HTTP2VerifyCacertPath + certPool, err := appendCerts(clientCAPath) + if err != nil { + zlog.Error().Err(err).Send() + return nil, err + } + + tlsConfig := &tls.Config{ + ClientAuth: tls.RequireAndVerifyClientCert, + ClientCAs: certPool, + } + s.Server.TLSConfig = tlsConfig + } + + if err := http2.ConfigureServer(&s.Server, h2s); err != nil { + return nil, err + } + + e.Pre(middleware.RemoveTrailingSlash()) + + e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{ + Skipper: func(c echo.Context) bool { + // /health の時はログを吐き出さない + return strings.HasPrefix(c.Request().URL.Path, "/.ok") + }, + })) + + e.Use(middleware.Recover()) + + // LB からのヘルスチェック専用 API + e.GET("/.ok", s.healthcheckHandler) + + serviceHandler, err := ServiceHandlers.getServiceHandler(service) + if err != nil { + return nil, err + } + e.POST("/speech", s.createSpeechHandler(service, serviceHandler)) + e.POST("/test", s.createSpeechHandler(service, TestHandler)) + e.POST("/dump", s.createSpeechHandler(service, PacketDumpHandler)) + + echoExporter := echo.New() + echoExporter.HideBanner = true + prom := prometheus.NewPrometheus("echo", nil) + + e.Use(prom.HandlerFunc) + prom.SetMetricsPath(echoExporter) + + s.echo = e + s.echoExporter = echoExporter + + zlog.Info().Str("serviceType", service).Send() + + return s, nil +} + +func (s *Server) Start(ctx context.Context, address string, port int) error { + http2FullchainFile := s.config.HTTP2FullchainFile + http2PrivkeyFile := s.config.HTTP2PrivkeyFile + + if _, err := os.Stat(http2FullchainFile); err != nil { + return fmt.Errorf("http2FullchainFile error: %s", err) + } + + if _, err := os.Stat(http2PrivkeyFile); err != nil { + return fmt.Errorf("http2PrivkeyFile error: %s", err) + } + + ch := make(chan error) + go func() { + defer close(ch) + if err := s.ListenAndServeTLS(http2FullchainFile, http2PrivkeyFile); err != http.ErrServerClosed { + ch <- err + } + }() + + defer func() { + if err := s.Shutdown(ctx); err != nil { + zlog.Error().Err(err).Send() + } + }() + + select { + case <-ctx.Done(): + return ctx.Err() + case err := <-ch: + return err + } + +} + +func (s *Server) StartExporter(ctx context.Context, address string, port int) error { + ch := make(chan error) + go func() { + err := s.echoExporter.Start(net.JoinHostPort(address, strconv.Itoa(port))) + if err != nil { + ch <- err + } + }() + + defer func() { + if err := s.echoExporter.Shutdown(ctx); err != nil { + zlog.Error().Err(err).Send() + } + }() + + select { + case <-ctx.Done(): + return ctx.Err() + case err := <-ch: + return err + } +} + +func appendCerts(clientCAPath string) (*x509.CertPool, error) { + certPool := x509.NewCertPool() + fi, err := os.Stat(clientCAPath) + if err != nil { + return nil, err + } + if fi.IsDir() { + files, err := os.ReadDir(clientCAPath) + if err != nil { + return nil, err + } + for _, f := range files { + clientCAPath := filepath.Join(clientCAPath, f.Name()) + if err := appendCertsFromPEM(certPool, clientCAPath); err != nil { + return nil, err + } + } + } else { + if err := appendCertsFromPEM(certPool, clientCAPath); err != nil { + return nil, err + } + } + return certPool, nil +} + +func appendCertsFromPEM(certPool *x509.CertPool, filepath string) error { + clientCA, err := os.ReadFile(filepath) + if err != nil { + return err + } + ok := certPool.AppendCertsFromPEM(clientCA) + if !ok { + return fmt.Errorf("failed to append certificates: %s", filepath) + } + return nil +} diff --git a/speech_to_text.go b/speech_to_text.go new file mode 100644 index 0000000..ea7afef --- /dev/null +++ b/speech_to_text.go @@ -0,0 +1,150 @@ +package suzu + +import ( + "context" + "io" + + speech "cloud.google.com/go/speech/apiv1" + zlog "github.com/rs/zerolog/log" + "google.golang.org/api/option" + "google.golang.org/protobuf/types/known/wrapperspb" + + speechpb "cloud.google.com/go/speech/apiv1/speechpb" +) + +type SpeechToText struct{} + +func NewSpeechToText() SpeechToText { + return SpeechToText{} +} + +func (stt SpeechToText) Start(ctx context.Context, config Config, args HandlerArgs, r io.Reader) (speechpb.Speech_StreamingRecognizeClient, error) { + recognitionConfig := NewRecognitionConfig(config, args) + speechpbRecognitionConfig := NewSpeechpbRecognitionConfig(recognitionConfig) + streamingRecognitionConfig := NewStreamingRecognitionConfig(speechpbRecognitionConfig, config.GcpSingleUtterance, config.GcpInterimResults) + + var opts []option.ClientOption + credentialFile := config.GcpCredentialFile + if credentialFile != "" { + opts = append(opts, option.WithCredentialsFile(credentialFile)) + } + + client, err := speech.NewClient(ctx, opts...) + if err != nil { + return nil, err + } + stream, err := client.StreamingRecognize(ctx) + if err != nil { + return nil, err + } + + if err := stream.Send(&speechpb.StreamingRecognizeRequest{ + StreamingRequest: streamingRecognitionConfig, + }); err != nil { + return nil, err + } + + go func() { + defer stream.CloseSend() + for { + buf := make([]byte, FrameSize) + n, err := r.Read(buf) + if err != nil { + if err != io.EOF { + // TODO: エラー処理 + zlog.Error().Err(err).Send() + } + return + } + if n > 0 { + audioContent := buf[:n] + if err := stream.Send(&speechpb.StreamingRecognizeRequest{ + StreamingRequest: &speechpb.StreamingRecognizeRequest_AudioContent{ + AudioContent: audioContent, + }, + }); err != nil { + // TODO: エラー処理 + zlog.Error().Err(err).Send() + return + } + } + } + }() + + return stream, nil +} + +type RecognitionConfig struct { + Encoding speechpb.RecognitionConfig_AudioEncoding + SampleRateHertz int32 + AudioChannelCount int32 + EnableSeparateRecognitionPerChannel bool + LanguageCode string + AlternativeLanguageCodes []string + MaxAlternatives int32 + ProfanityFilter bool + SpeechContexts []*speechpb.SpeechContext + EnableWordTimeOffsets bool + EnableWordConfidence bool + EnableAutomaticPunctuation bool + EnableSpokenPunctuation bool + EnableSpokenEmojis bool + Model string + UseEnhanced bool +} + +func NewRecognitionConfig(c Config, args HandlerArgs) RecognitionConfig { + return RecognitionConfig{ + Encoding: speechpb.RecognitionConfig_OGG_OPUS, + SampleRateHertz: int32(args.SampleRate), + AudioChannelCount: int32(args.ChannelCount), + EnableSeparateRecognitionPerChannel: c.GcpEnableSeparateRecognitionPerChannel, + LanguageCode: args.LanguageCode, + AlternativeLanguageCodes: c.GcpAlternativeLanguageCodes, + MaxAlternatives: c.GcpMaxAlternatives, + ProfanityFilter: c.GcpProfanityFilter, + SpeechContexts: []*speechpb.SpeechContext{ + // &speechpb.SpeechContext{ + // Phrases: []string{}, + // }, + }, + EnableWordTimeOffsets: c.GcpEnableWordTimeOffsets, + EnableWordConfidence: c.GcpEnableWordConfidence, + EnableAutomaticPunctuation: c.GcpEnableAutomaticPunctuation, + EnableSpokenPunctuation: c.GcpEnableSpokenPunctuation, + EnableSpokenEmojis: c.GcpEnableSpokenEmojis, + Model: c.GcpModel, + UseEnhanced: c.GcpUseEnhanced, + } +} + +func NewSpeechpbRecognitionConfig(rc RecognitionConfig) *speechpb.RecognitionConfig { + return &speechpb.RecognitionConfig{ + Encoding: rc.Encoding, + SampleRateHertz: rc.SampleRateHertz, + AudioChannelCount: rc.AudioChannelCount, + EnableSeparateRecognitionPerChannel: rc.EnableSeparateRecognitionPerChannel, + LanguageCode: rc.LanguageCode, + AlternativeLanguageCodes: rc.AlternativeLanguageCodes, + MaxAlternatives: rc.MaxAlternatives, + ProfanityFilter: rc.ProfanityFilter, + SpeechContexts: rc.SpeechContexts, + EnableWordTimeOffsets: rc.EnableWordTimeOffsets, + EnableWordConfidence: rc.EnableWordConfidence, + EnableAutomaticPunctuation: rc.EnableAutomaticPunctuation, + EnableSpokenPunctuation: wrapperspb.Bool(rc.EnableSpokenPunctuation), + EnableSpokenEmojis: wrapperspb.Bool(rc.EnableSpokenEmojis), + Model: rc.Model, + UseEnhanced: rc.UseEnhanced, + } +} + +func NewStreamingRecognitionConfig(recognitionConfig *speechpb.RecognitionConfig, singleUtterance, interimResults bool) *speechpb.StreamingRecognizeRequest_StreamingConfig { + return &speechpb.StreamingRecognizeRequest_StreamingConfig{ + StreamingConfig: &speechpb.StreamingRecognitionConfig{ + Config: recognitionConfig, + SingleUtterance: singleUtterance, + InterimResults: interimResults, + }, + } +} diff --git a/speech_to_text_handler.go b/speech_to_text_handler.go new file mode 100644 index 0000000..e0d0889 --- /dev/null +++ b/speech_to_text_handler.go @@ -0,0 +1,95 @@ +package suzu + +import ( + "context" + "encoding/json" + "io" + "time" + + zlog "github.com/rs/zerolog/log" +) + +func init() { + ServiceHandlers.registerHandler("gcp", SpeechToTextHandler) +} + +func SpeechToTextHandler(ctx context.Context, conn io.Reader, args HandlerArgs) (*io.PipeReader, error) { + + d := time.Duration(args.Config.TimeToWaitForOpusPacketMs) * time.Millisecond + + reader, err := readerWithSilentPacketFromOpusReader(d, conn) + if err != nil { + return nil, err + } + + oggReader, oggWriter := io.Pipe() + + go func() { + defer oggWriter.Close() + if err := opus2ogg(ctx, reader, oggWriter, args.SampleRate, args.ChannelCount, args.Config); err != nil { + oggWriter.CloseWithError(err) + return + } + }() + + stt := NewSpeechToText() + stream, err := stt.Start(ctx, args.Config, args, oggReader) + if err != nil { + oggWriter.CloseWithError(err) + return nil, err + } + + r, w := io.Pipe() + + go func() { + encoder := json.NewEncoder(w) + + for { + resp, err := stream.Recv() + if err != nil { + w.CloseWithError(err) + return + } + if err := resp.Error; err != nil { + // TODO: 音声の長さの上限値に達した場合の処理の追加 + // if err.Code == 3 || err.Code == 11 { + // } + zlog.Error(). + Str("CHANNEL-ID", args.SoraChannelID). + Str("CONNECTION-ID", args.SoraConnectionID). + Str("MESSAGE", err.GetMessage()). + Int32("CODE", err.GetCode()). + Send() + w.Close() + return + } + + for _, result := range resp.Results { + for _, alternative := range result.Alternatives { + if args.Config.GcpEnableWordConfidence { + for _, word := range alternative.Words { + zlog.Debug(). + Str("CHANNEL-ID", args.SoraChannelID). + Str("CONNECTION-ID", args.SoraConnectionID). + Str("Wrod", word.Word). + Float32("Confidence", word.Confidence). + Str("StartTime", word.StartTime.String()). + Str("EndTime", word.EndTime.String()). + Send() + } + } + transcript := alternative.Transcript + resp := Response{ + Message: transcript, + } + if err := encoder.Encode(resp); err != nil { + w.CloseWithError(err) + return + } + } + } + } + }() + + return r, nil +} diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 0000000..5f0a348 --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1 @@ +checks = ["all", "-ST1000"] diff --git a/test_handler.go b/test_handler.go new file mode 100644 index 0000000..30e5d07 --- /dev/null +++ b/test_handler.go @@ -0,0 +1,59 @@ +package suzu + +import ( + "context" + "encoding/json" + "fmt" + "io" + "time" +) + +func TestHandler(ctx context.Context, opusReader io.Reader, args HandlerArgs) (*io.PipeReader, error) { + c := args.Config + + d := time.Duration(c.TimeToWaitForOpusPacketMs) * time.Millisecond + + reader, err := readerWithSilentPacketFromOpusReader(d, opusReader) + if err != nil { + return nil, err + } + + oggReader, oggWriter := io.Pipe() + + go func() { + if err := opus2ogg(ctx, reader, oggWriter, args.SampleRate, args.ChannelCount, args.Config); err != nil { + oggWriter.CloseWithError(err) + return + } + + oggWriter.Close() + }() + + r, w := io.Pipe() + + go func() { + encoder := json.NewEncoder(w) + + for { + buf := make([]byte, FrameSize) + n, err := oggReader.Read(buf) + if err != nil { + w.CloseWithError(err) + return + } + + if n > 0 { + res := Response{ + ChannelID: &[]string{"ch_0"}[0], + Message: fmt.Sprintf("n: %d", n), + } + if err := encoder.Encode(res); err != nil { + w.CloseWithError(err) + return + } + } + } + }() + + return r, nil +} diff --git a/testdata/dump.jsonl b/testdata/dump.jsonl new file mode 100644 index 0000000..0052f5a --- /dev/null +++ b/testdata/dump.jsonl @@ -0,0 +1,9 @@ +{"timestamp":1667274760504,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760521,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760544,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760562,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760585,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760603,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760626,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760643,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"} +{"timestamp":1667274760666,"channel_id":"sora","connection_id":"JG6CSF8P6D3PS61FW1S4KGK8FM","language_code":"ja-JP","sample_rate":48000,"channel_count":2,"payload":"/P/+"}