-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add prompting support #8 (upd to 1.3.0) * fix C# 9 target-typed new (for Unity 2019/2020) * fixes (#25)
- Loading branch information
1 parent
8532481
commit 269eea8
Showing
8 changed files
with
2,000 additions
and
207 deletions.
There are no files selected for viewing
2,017 changes: 1,814 additions & 203 deletions
2,017
Assets/Samples/1 - Audio Clip/1 - Audio Clip.unity
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Packages/com.whisper.unity/Tests/Runtime/WhisperPromptTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System.IO; | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
|
||
namespace Whisper.Tests | ||
{ | ||
[TestFixture] | ||
public class WhisperPromptTests | ||
{ | ||
private readonly string _modelPath = Path.Combine(Application.streamingAssetsPath, "Whisper/ggml-tiny.bin"); | ||
private readonly float[] _buffer = new float[32000]; | ||
private const int Frequency = 8000; | ||
private const int Channels = 2; | ||
|
||
private WhisperWrapper _whisper; | ||
private WhisperParams _params; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_whisper = WhisperWrapper.InitFromFile(_modelPath); | ||
_params = WhisperParams.GetDefaultParams(); | ||
} | ||
|
||
[Test] | ||
public void RunWithNullPrompt() | ||
{ | ||
_params.InitialPrompt = null; | ||
|
||
var res = _whisper.GetText(_buffer, Frequency, Channels, _params); | ||
Assert.NotNull(res); | ||
} | ||
|
||
[Test] | ||
public void RunWithEmptyPrompt() | ||
{ | ||
_params.InitialPrompt = ""; | ||
|
||
var res = _whisper.GetText(_buffer, Frequency, Channels, _params); | ||
Assert.NotNull(res); | ||
} | ||
|
||
[Test] | ||
public void TextDiffersDueToPrompt() | ||
{ | ||
var clip = AudioClip.Create("test", _buffer.Length, Channels, Frequency, false); | ||
|
||
var res1 = _whisper.GetText(clip, _params); | ||
Assert.NotNull(res1); | ||
|
||
_params.InitialPrompt = "hello how is it going always use lowercase no punctuation goodbye one two three start stop i you me they" + | ||
" EVERY WORD IS WRITTEN IN CAPITAL LETTERS AS IF THE CAPS LOCK KEY WAS PRESSED" + | ||
". This long prompt should change the result a lot, i hope!"; | ||
var res2 = _whisper.GetText(clip, _params); | ||
Assert.NotNull(res2); | ||
|
||
Assert.True(res1.Result != res2.Result); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Packages/com.whisper.unity/Tests/Runtime/WhisperPromptTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.