Skip to content

Commit dff80e3

Browse files
committed
Update documents
1 parent 26d4283 commit dff80e3

File tree

3 files changed

+66
-99
lines changed

3 files changed

+66
-99
lines changed

CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.1.0] - 2023-03-08
10+
## [1.0.0] - 2023-07-03
1111

1212
### Added
13+
- Add logging by `com.unity.logging`.
14+
- Add detailed error handling by `Relent`.
15+
16+
### Changed
17+
- Renewal interface of transcription API using `Relent` and `UniTask`.
18+
- Renewal interface of translation API using `Relent` and `UniTask`.
19+
- Rename directory, namespace and assembly from `Whisper_API` to `WhisperAPI`.
20+
- Change Unity version from 2021.3 to 2022.3.
21+
22+
### Fixed
23+
- Fix to set optional request parameters.
1324

14-
- Implement Whisper transctiption API bindings to C#.
15-
- Implement sample component of transctiption.
25+
## [0.1.0] - 2023-03-08
26+
27+
### Added
28+
- Implement Whisper transcription API bindings to C#.
29+
- Implement sample component of transcription.
1630
- Implement Whisper translation API bindings to C#.
1731
- Implement sample component of translation.

NOTICE.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NOTICE
22

3-
This repository use these 3rd party libraries via UnityPackageManager.
3+
This repository uses following 3rd party libraries via Unity Package Manager.
44

55
## NewtonSoft Json
66

@@ -67,7 +67,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6767
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6868
```
6969

70-
7170
## Fluent Assertions for Unity
7271

7372
https://github.com/BoundfoxStudios/fluentassertions-unity
@@ -276,12 +275,10 @@ https://github.com/BoundfoxStudios/fluentassertions-unity
276275
limitations under the License.
277276
```
278277

279-
280278
## UniTask
281279

282280
https://github.com/Cysharp/UniTask
283281

284-
285282
```
286283
The MIT License (MIT)
287284
@@ -297,6 +294,34 @@ furnished to do so, subject to the following conditions:
297294
The above copyright notice and this permission notice shall be included in all
298295
copies or substantial portions of the Software.
299296
297+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
298+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
299+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
300+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
301+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
302+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
303+
SOFTWARE.
304+
```
305+
306+
## Relent
307+
308+
https://github.com/mochi-neko/Relent
309+
310+
```
311+
MIT License
312+
313+
Copyright (c) 2023 mochineko
314+
315+
Permission is hereby granted, free of charge, to any person obtaining a copy
316+
of this software and associated documentation files (the "Software"), to deal
317+
in the Software without restriction, including without limitation the rights
318+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
319+
copies of the Software, and to permit persons to whom the Software is
320+
furnished to do so, subject to the following conditions:
321+
322+
The above copyright notice and this permission notice shall be included in all
323+
copies or substantial portions of the Software.
324+
300325
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
301326
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
302327
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

README.md

Lines changed: 20 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,45 @@
11
# Whisper-API-unity
2-
Binds [Whisper transcription and translation API](https://platform.openai.com/docs/api-reference/audio) to pure C# on Unity.
2+
A client library of OpenAI [Whisper transcription and translation API](https://platform.openai.com/docs/api-reference/audio) for Unity.
33

44
See also [official document](https://platform.openai.com/docs/guides/speech-to-text).
55

6-
## How to import by UnityPackageManager
6+
## Features
77

8-
Add dependencies:
8+
- Transcription
9+
- Speech audio file to text in speeched language.
10+
- Translation
11+
- Speech audio file to text in English.
12+
13+
## How to import by Unity Package Manager
14+
15+
Add following dependencies to your `/Packages/manifest.json`.
916

1017
```json
1118
{
1219
"dependencies": {
13-
"com.mochineko.whisper-api": "https://github.com/mochi-neko/Whisper-API-unity.git?path=/Assets/Mochineko/Whisper_API#0.1.0",
14-
"com.unity.nuget.newtonsoft-json": "3.0.2",
20+
"com.mochineko.whisper-api": "https://github.com/mochi-neko/Whisper-API-unity.git?path=/Assets/Mochineko/Whisper_API#1.0.0",
1521
...
1622
}
1723
}
1824
```
1925

20-
to your `mainfest.json`.
21-
22-
If you have already used Newtonsoft.Json on your project, remove dependency:`"com.unity.nuget.newtonsoft-json": "3.0.2",`.
23-
24-
## How to use transcription speech audio into text by Whisper API
25-
26-
1. Generate API key on [OpenAI](https://platform.openai.com/account/api-keys). (Take care your API key, this is a secret information then you should not open.)
27-
2. Create an instance of `WhisperTranscriptionConnection` with API key.
28-
3. Set file path of speech audio e.g. `/some/path/of/file/audio.mp3`, and call `WhisperTranscriptionConnection.TranscribeFromFileAsync`.
29-
4. Because deault response text format is JSON, you can exclude text by `APIResponseBody.FromJson(json)?.Text`.
26+
## How to use
3027

31-
An essential sample code of transcription with [UniTask](https://github.com/Cysharp/UniTask) is as follows:
32-
33-
```cs
34-
#nullable enable
35-
using System;
36-
using Cysharp.Threading.Tasks;
37-
using UnityEngine;
38-
using UnityEngine.Assertions;
39-
using Mochineko.Whisper_API.;
40-
using Mochineko.Whisper_API.Transcription;
41-
42-
namespace XXX
43-
{
44-
/// <summary>
45-
/// A sample component to transcribe speech by Whisper API on Unity.
46-
/// </summary>
47-
public sealed class TranscriptionSample : MonoBehaviour
48-
{
49-
/// <summary>
50-
/// API key generated by OpenAPI.
51-
/// </summary>
52-
[SerializeField] private string apiKey = string.Empty;
53-
54-
/// <summary>
55-
/// File path of speech audio.
56-
/// </summary>
57-
[SerializeField] private string filePath = string.Empty;
58-
59-
private WhisperTranscriptionConnection? connection;
60-
61-
private void Start()
62-
{
63-
// Create instance of WhisperTranscriptionConnection.
64-
connection = new WhisperTranscriptionConnection(apiKey);
65-
66-
// If you want to specify response format, language, etc..., please use other initialization:
67-
// connection = new WhisperTranscriptionConnection(apiKey, new APIRequestBody(
68-
// file: "",
69-
// model: "whisper-1",
70-
// prompt: "Some prompts",
71-
// responseFormat: "json",
72-
// temperature: 1f,
73-
// language: "ja"));
74-
}
75-
76-
[ContextMenu(nameof(Transcribe))]
77-
public async void Transcribe()
78-
{
79-
string result;
80-
try
81-
{
82-
// Transcribe speech by Whisper speech to text API.
83-
result = await connection
84-
.TranscribeFromFileAsync(filePath, this.GetCancellationTokenOnDestroy());
85-
}
86-
catch (Exception e)
87-
{
88-
// Exceptions should be caught.
89-
Debug.LogException(e);
90-
return;
91-
}
92-
93-
// Default text response format is JSON.
94-
var text = APIResponseBody.FromJson(result)?.Text;
95-
96-
// Log text result.
97-
Debug.Log($"[Whisper_API.Transcription.Samples] Result:\n{text}");
98-
}
99-
}
100-
}
101-
```
28+
Please generate your API key on [OpenAI](https://platform.openai.com/account/api-keys).
10229

103-
See also [Sample](https://github.com/mochi-neko/Whisper-API-unity/blob/main/Assets/Mochineko/Whisper_API.Samples/Transcription/TranscriptionSample.cs).
30+
See [sample codes](./Assets/Mochineko/WhisperAPI.Samples).
10431

105-
Translation (translate speech audio into English text) sample is [here](https://github.com/mochi-neko/Whisper-API-unity/blob/main/Assets/Mochineko/Whisper_API.Samples/Transcription/TranscriptionSample.cs).
32+
You can customize handling of retries to fit needs of your project by [Relent](https://github.com/mochi-neko/Relent),
33+
e.g. [PolicyFactory](./Assets/Mochineko/WhisperAPI.Samples/PolicyFactory.cs).
10634

10735
## Changelog
10836

109-
See [CHANGELOG](https://github.com/mochi-neko/Whisper-API-unity/blob/main/CHANGELOG.md)
37+
See [CHANGELOG](./CHANGELOG.md).
11038

111-
## 3rd Party Notices
39+
## 3rd party notices
11240

113-
See [NOTICE](https://github.com/mochi-neko/Whisper-API-unity/blob/main/NOTICE.md).
41+
See [NOTICE](./NOTICE.md).
11442

11543
## License
11644

117-
[MIT License](https://github.com/mochi-neko/Whisper-API-unity/blob/main/LICENSE)
45+
Licensed under the [MIT](./LICENSE) License.

0 commit comments

Comments
 (0)