diff --git a/CHANGES.md b/CHANGES.md index 0d40588..f916279 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,11 @@ - [UPDATE] GitHub Actions の staticcheck のバージョンを 2024.1.1 に上げる - @Hexa +## 2024.10.0 + +- [CHANGE] Amazon Transcribe 向けの minimum_confidence_score と minimum_transcribed_time が両方ともに無効(0)に設定されていた場合は、フィルタリングしない結果を返すように変更する + - @Hexa + ## 2024.9.0 - [CHANGE] Amazon Transcribe 向けの minimum_confidence_score と minimum_transcribed_time を独立させて、minimum_confidence_score が無効でも minimum_transcribed_time が有効な場合は minimum_transcribed_time でのフィルタリングが有効になるように変更する diff --git a/VERSION b/VERSION index d630040..03a7cca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2024.9.0 +2024.10.0 diff --git a/amazon_transcribe_handler.go b/amazon_transcribe_handler.go index 2cbbe6a..adc73cc 100644 --- a/amazon_transcribe_handler.go +++ b/amazon_transcribe_handler.go @@ -254,6 +254,15 @@ func contentFilterByConfidenceScore(config Config, item transcribestreamingservi func buildMessage(config Config, alt transcribestreamingservice.Alternative, isPartial bool) (string, bool) { var message string + + minimumTranscribedTime := config.MinimumTranscribedTime + minimumConfidenceScore := config.MinimumConfidenceScore + + // 両方無効の場合には全てのメッセージを返す + if (minimumTranscribedTime <= 0) && (minimumConfidenceScore <= 0) { + return *alt.Transcript, true + } + items := alt.Items includePronunciation := false diff --git a/amazon_transcribe_handler_test.go b/amazon_transcribe_handler_test.go index 1895f13..353714c 100644 --- a/amazon_transcribe_handler_test.go +++ b/amazon_transcribe_handler_test.go @@ -20,6 +20,58 @@ func TestBuildMessage(t *testing.T) { Ok bool } + t.Run("default", func(t *testing.T) { + testCases := []struct { + Name string + Config Config + Input Input + Expect Expect + }{ + { + Name: "minimumTranscribedTime == 0 && minimumConfidenceScore == 0", + Config: Config{ + MinimumTranscribedTime: 0, + MinimumConfidenceScore: 0, + }, + Input: Input{ + Alt: transcribestreamingservice.Alternative{ + Transcript: aws.String("filter is disabled"), + Items: []*transcribestreamingservice.Item{ + { + StartTime: aws.Float64(0), + EndTime: aws.Float64(1), + Confidence: aws.Float64(1), + Content: aws.String("test"), + Type: aws.String(transcribestreamingservice.ItemTypePronunciation), + }, + { + StartTime: aws.Float64(0), + EndTime: aws.Float64(1), + Confidence: aws.Float64(1), + Content: aws.String("data"), + Type: aws.String(transcribestreamingservice.ItemTypePronunciation), + }, + }, + }, + IsPartial: false, + }, + Expect: Expect{ + Message: "filter is disabled", + Ok: true, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.Name, func(t *testing.T) { + actual, ok := buildMessage(tc.Config, tc.Input.Alt, tc.Input.IsPartial) + assert.Equal(t, tc.Expect.Ok, ok) + assert.Equal(t, tc.Expect.Message, actual) + }) + } + + }) + t.Run("minimumTranscribedTime", func(t *testing.T) { testCases := []struct { Name string @@ -31,21 +83,24 @@ func TestBuildMessage(t *testing.T) { Name: "minimumTranscribedTime is 0", Config: Config{ MinimumTranscribedTime: 0, + MinimumConfidenceScore: 0.1, }, Input: Input{ Alt: transcribestreamingservice.Alternative{ Items: []*transcribestreamingservice.Item{ { - StartTime: aws.Float64(0), - EndTime: aws.Float64(0), - Content: aws.String("test"), - Type: aws.String(transcribestreamingservice.ItemTypePronunciation), + StartTime: aws.Float64(0), + EndTime: aws.Float64(0), + Confidence: aws.Float64(1), + Content: aws.String("test"), + Type: aws.String(transcribestreamingservice.ItemTypePronunciation), }, { - StartTime: aws.Float64(0), - EndTime: aws.Float64(0), - Content: aws.String("data"), - Type: aws.String(transcribestreamingservice.ItemTypePronunciation), + StartTime: aws.Float64(0), + EndTime: aws.Float64(0), + Confidence: aws.Float64(1), + Content: aws.String("data"), + Type: aws.String(transcribestreamingservice.ItemTypePronunciation), }, }, }, @@ -223,6 +278,7 @@ func TestBuildMessage(t *testing.T) { { Name: "minimumConfidenceScore is 0", Config: Config{ + MinimumTranscribedTime: 0.01, MinimumConfidenceScore: 0, }, Input: Input{ @@ -231,14 +287,14 @@ func TestBuildMessage(t *testing.T) { { Confidence: aws.Float64(0), StartTime: aws.Float64(0), - EndTime: aws.Float64(0), + EndTime: aws.Float64(1), Content: aws.String("test"), Type: aws.String(transcribestreamingservice.ItemTypePronunciation), }, { Confidence: aws.Float64(0), StartTime: aws.Float64(0), - EndTime: aws.Float64(0), + EndTime: aws.Float64(1), Content: aws.String("data"), Type: aws.String(transcribestreamingservice.ItemTypePronunciation), }, @@ -429,6 +485,7 @@ func TestBuildMessage(t *testing.T) { { Name: "minimumConfidenceScore is 0", Config: Config{ + MinimumTranscribedTime: 0.01, MinimumConfidenceScore: 0, }, Input: Input{ @@ -437,14 +494,14 @@ func TestBuildMessage(t *testing.T) { { Confidence: aws.Float64(0), StartTime: aws.Float64(0), - EndTime: aws.Float64(0), + EndTime: aws.Float64(1), Content: aws.String("test"), Type: aws.String(transcribestreamingservice.ItemTypePronunciation), }, { Confidence: aws.Float64(0), StartTime: aws.Float64(0), - EndTime: aws.Float64(0), + EndTime: aws.Float64(1), Content: aws.String("data"), Type: aws.String(transcribestreamingservice.ItemTypePronunciation), }, diff --git a/config_example.ini b/config_example.ini index e5ce1cd..b9578a3 100644 --- a/config_example.ini +++ b/config_example.ini @@ -55,12 +55,17 @@ retry_interval_ms = 100 # aws の場合は IsPartial が false, gcp の場合は IsFinal が true の場合の最終的な結果のみを返す指定 final_result_only = true + # 採用する結果の信頼スコアの最小値です(aws 指定時のみ有効) +# minimum_confidence_score が 0.0 の場合は信頼スコアによるフィルタリングは無効です # minimum_confidence_score = 0.0 # 採用する結果の最小発話期間(秒)です(aws 指定時のみ有効) +# minimum_transcribed_time が 0.0 の場合は発話期間によるフィルタリングは無効です # minimum_transcribed_time = 0.0 +# minimum_confidence_score と minimum_transcribed_time の両方が無効の場合はフィルタリングしません + # [aws] aws_region = ap-northeast-1 # Partial-result stabilization の有効化です diff --git a/doc/DEV.md b/doc/DEV.md index d6da5f3..f8906e8 100644 --- a/doc/DEV.md +++ b/doc/DEV.md @@ -5,7 +5,6 @@ 初回だけ make init と設定を cp する必要があります。 ```console -$ make init $ cp config_example.ini config.ini ``` diff --git a/doc/USE.md b/doc/USE.md index 52b7639..a64f8a7 100644 --- a/doc/USE.md +++ b/doc/USE.md @@ -72,4 +72,4 @@ GCP Speech-to-Text を利用するに当たっての注意事項は [GCP.md](GCP ### /dump この URL を Sora の audio_streaming_url を指定すると、 -音声ストリミーングに流れてくる音声データを JSON 形式でダンプします。 +音声ストリーミングに流れてくる音声データを JSON 形式でダンプします。