From dfd659e7b9ce807034e73029b603b61504be36fa Mon Sep 17 00:00:00 2001 From: Yoshida Hiroshi Date: Tue, 17 Dec 2024 12:08:34 +0900 Subject: [PATCH] =?UTF-8?q?-=20=E8=A8=AD=E5=AE=9A=E3=81=AB=20minimum=5Fcon?= =?UTF-8?q?fidence=5Fscore,=20minimum=5Ftranscribed=5Ftime=20=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=20-=20MinimumTranscribedTi?= =?UTF-8?q?me=20=E3=81=AE=E6=8C=87=E5=AE=9A=E3=82=92=E7=A7=92=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 7 +++++++ amazon_transcribe_handler.go | 4 ++-- config.go | 4 ++-- config_example.ini | 6 ++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e4b073c..0401c9b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,13 @@ ## develop +- [ADD] 採用する結果の信頼スコアの最小値を指定する minimum_confidence_score を追加する + - デフォルト値: 0(信頼スコアを無視する) + - @Hexa +- [ADD] 採用する結果の最小発話期間(秒)を指定する minimum_transcribed_time を追加する + - デフォルト値: 0(最小発話期間を無視する) + - @Hexa + ### misc ## 2024.7.0 diff --git a/amazon_transcribe_handler.go b/amazon_transcribe_handler.go index 8aa9222..06b04c8 100644 --- a/amazon_transcribe_handler.go +++ b/amazon_transcribe_handler.go @@ -200,7 +200,7 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, opusCh chan opusCh func buildMessage(config Config, alt transcribestreamingservice.Alternative, isPartial bool) (string, bool) { minimumConfidenceScore := config.MinimumConfidenceScore - minimumTranscribedTimeMs := config.MinimumTranscribedTimeMs + minimumTranscribedTime := config.MinimumTranscribedTime var message string if minimumConfidenceScore > 0 { @@ -222,7 +222,7 @@ func buildMessage(config Config, alt transcribestreamingservice.Alternative, isP if (item.StartTime != nil) && (item.EndTime != nil) { if (*item.EndTime - *item.StartTime) > 0 { - if (*item.EndTime - *item.StartTime) < minimumTranscribedTimeMs { + if (*item.EndTime - *item.StartTime) < minimumTranscribedTime { // 発話時間が短い場合は次へ continue } diff --git a/config.go b/config.go index 56a110e..aeba0ad 100644 --- a/config.go +++ b/config.go @@ -79,8 +79,8 @@ type Config struct { // aws の場合は IsPartial が false, gcp の場合は IsFinal が true の場合にのみ結果を返す指定 FinalResultOnly bool `ini:"final_result_only"` - MinimumConfidenceScore float64 `ini:"minimum_confidence_score"` - MinimumTranscribedTimeMs float64 `ini:"minimum_transcribed_time_ms"` + MinimumConfidenceScore float64 `ini:"minimum_confidence_score"` + MinimumTranscribedTime float64 `ini:"minimum_transcribed_time"` // Amazon Web Services AwsCredentialFile string `ini:"aws_credential_file"` diff --git a/config_example.ini b/config_example.ini index 19b71db..fb910d3 100644 --- a/config_example.ini +++ b/config_example.ini @@ -55,6 +55,12 @@ retry_interval_ms = 100 # aws の場合は IsPartial が false, gcp の場合は IsFinal が true の場合の最終的な結果のみを返す指定 final_result_only = true +# 採用する結果の信頼スコアの最小値です +# minimum_confidence_score = 0.0 + +# 採用する結果の最小発話期間(秒)です +# minimum_transcribed_time = 0.0 + # [aws] aws_region = ap-northeast-1 # Partial-result stabilization の有効化です