Skip to content

Commit 6547801

Browse files
committed
Refactor
1 parent f37529b commit 6547801

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Assets/Mochineko/Whisper_API.Tests/TranscriptionTest.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Threading;
44
using System.Threading.Tasks;
5+
using FluentAssertions;
56
using Mochineko.Relent.UncertainResult;
67
using NUnit.Framework;
78
using UnityEngine;
@@ -29,7 +30,7 @@ public async Task Transcribe()
2930

3031
using var httpClient = new System.Net.Http.HttpClient();
3132

32-
var result = await TranscriptionAPI
33+
var apiResult = await TranscriptionAPI
3334
.TranscribeFromFileAsync(
3435
apiKey,
3536
httpClient,
@@ -38,11 +39,12 @@ public async Task Transcribe()
3839
file: filePath,
3940
Model.Whisper1),
4041
CancellationToken.None);
41-
switch (result)
42+
switch (apiResult)
4243
{
4344
case IUncertainSuccessResult<string> success:
44-
var json = TranscriptionResponseBody.FromJson(success.Result);
45-
Debug.Log($"Result:\n{json?.Text}");
45+
var result = TranscriptionResponseBody.FromJson(success.Result)?.Text;
46+
Debug.Log($"[Whisper_API.Tests] Result: {result}.");
47+
result?.Should().Be("とりあえず店の前、掃除しといてくれ。 内水も頼む。");
4648
break;
4749

4850
case IUncertainRetryableResult<string> retryable:
@@ -54,7 +56,7 @@ public async Task Transcribe()
5456
break;
5557

5658
default:
57-
throw new UncertainResultPatternMatchException(nameof(result));
59+
throw new UncertainResultPatternMatchException(nameof(apiResult));
5860
}
5961
}
6062
}

Assets/Mochineko/Whisper_API/TranscriptionAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static async UniTask<IUncertainResult<string>> TranscribeAsync(
4949

5050
if (cancellationToken.IsCancellationRequested)
5151
{
52-
return UncertainResults.RetryWithTrace<string>($"Already canceled.");
52+
return UncertainResults.RetryWithTrace<string>($"Already cancelled.");
5353
}
5454

5555
// Create request

0 commit comments

Comments
 (0)