Skip to content

Commit 056cc7a

Browse files
committed
fix typos
1 parent aa78c58 commit 056cc7a

112 files changed

Lines changed: 33982 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Runtime/Scripts/Core/ITextToSpeechService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public Task<string> CloneVoiceAndGetVoiceIDAsync(
9494
bool removeBackgroundNoise = false);
9595

9696
/// <summary>
97-
/// Ocurrs when the TTS service recieved audio data
97+
/// Ocurrs when the TTS service received audio data
9898
/// </summary>
99-
public event System.EventHandler<byte[]> OnAudioDataRecieved;
99+
public event System.EventHandler<byte[]> OnAudioDataReceived;
100100
}
101101
}

Assets/Runtime/Scripts/Services/ElevenlabsTTSServiceManager.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ namespace TimShaw.VoiceBox.Core
2626
public class ElevenLabsTTSServiceManager : ITextToSpeechService
2727
{
2828
/// <summary>
29-
/// Ocurrs when the TTS service recieved audio data
29+
/// Ocurrs when the TTS service received audio data
3030
/// </summary>
31-
public event System.EventHandler<byte[]> OnAudioDataRecieved;
31+
public event System.EventHandler<byte[]> OnAudioDataReceived;
3232

3333
private HttpClient client;
3434
/// <summary>
@@ -37,7 +37,7 @@ public class ElevenLabsTTSServiceManager : ITextToSpeechService
3737
private ElevenlabsTTSServiceConfig _config;
3838
private string fileExtension;
3939

40-
private Task _recieveAudioTask;
40+
private Task _receiveAudioTask;
4141

4242
/// <summary>
4343
/// Represents the request body for the ElevenLabs TTS API.
@@ -285,7 +285,7 @@ private async Task ReceiveAudioData(ClientWebSocket _webSocket, StreamingAudioDe
285285
byte[] audioBytes = Convert.FromBase64String(response.audio);
286286

287287
_audioDecoder.Feed(audioBytes, true);
288-
OnAudioDataRecieved?.Invoke(this, audioBytes.ToArray());
288+
OnAudioDataReceived?.Invoke(this, audioBytes.ToArray());
289289
}
290290
}
291291

@@ -334,7 +334,7 @@ public async Task ConnectAndStream(string text, ClientWebSocket _webSocket, Canc
334334
}
335335

336336
/// <summary>
337-
/// Sets the xi-api-key header and starts the <see cref="ReceiveAudioData(WebSocket, StreamingAudioDecoder, CancellationToken)"/> loop
337+
/// Sets the xi-api-key header and starts the <see cref="ReceiveAudioData(ClientWebSocket, StreamingAudioDecoder, CancellationToken)"/> loop
338338
/// </summary>
339339
/// <param name="webSocket">The websocket that should connect to Elevenlabs</param>
340340
/// <param name="audioDecoder">The MP3 decoder to process the audio stream.</param>
@@ -345,19 +345,19 @@ public void InitWebsocket(ClientWebSocket webSocket, StreamingAudioDecoder audio
345345
{
346346
Uri uri = new Uri($"wss://api.elevenlabs.io/v1/text-to-speech/{_config.voiceId}/stream-input?model_id={_config.modelID}");
347347
Task.Run(() => webSocket.ConnectAsync(uri, token)).Wait();
348-
if (_recieveAudioTask != null)
349-
_recieveAudioTask.Dispose();
350-
_recieveAudioTask = ReceiveAudioData(webSocket, audioDecoder, token);
348+
if (_receiveAudioTask != null)
349+
_receiveAudioTask.Dispose();
350+
_receiveAudioTask = ReceiveAudioData(webSocket, audioDecoder, token);
351351
return;
352352
}
353353
else if (webSocket.State != WebSocketState.Open && webSocket.State != WebSocketState.Connecting) // Initialize WebSocket
354354
{
355355
webSocket.Options.SetRequestHeader("xi-api-key", _config.apiKey);
356356
Uri uri = new Uri($"wss://api.elevenlabs.io/v1/text-to-speech/{_config.voiceId}/stream-input?model_id={_config.modelID}");
357357
Task.Run(() => webSocket.ConnectAsync(uri, token)).Wait();
358-
if (_recieveAudioTask != null)
359-
_recieveAudioTask.Dispose();
360-
_recieveAudioTask = ReceiveAudioData(webSocket, audioDecoder, token);
358+
if (_receiveAudioTask != null)
359+
_receiveAudioTask.Dispose();
360+
_receiveAudioTask = ReceiveAudioData(webSocket, audioDecoder, token);
361361
return;
362362
}
363363
else

Assets/Runtime/Scripts/Services/GeminiServiceManager.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ namespace TimShaw.VoiceBox.Core
1616
public class GeminiServiceManager : IChatService
1717
{
1818
private IChatClient _client;
19-
private GeminiServiceConfig _config;
19+
private GeminiServiceConfig _config; // If implementing a custom service, replace GeminiServiceConfig with your custom service config
2020

2121
/// <summary>
2222
/// Initializes the Gemini service with the provided configuration.
2323
/// </summary>
2424
/// <param name="config">The ScriptableObject configuration for the Gemini service.</param>
25-
public void Initialize(GenericChatServiceConfig config)
25+
public void Initialize(GenericChatServiceConfig config) // If implementing a custom service, replace GeminiServiceConfig with your custom service config
2626
{
2727
if (config is GeminiServiceConfig geminiConfig)
2828
{
@@ -36,8 +36,8 @@ public void Initialize(GenericChatServiceConfig config)
3636
if (_config.useFunctionInvokation)
3737
{
3838
_client = new ChatClientBuilder(
39-
new OpenAIClient(new System.ClientModel.ApiKeyCredential(config.apiKey), options).GetChatClient(config.modelName ?? "gemini-2.5-flash").AsIChatClient()
40-
).UseFunctionInvocation().Build();
39+
new OpenAIClient(new System.ClientModel.ApiKeyCredential(config.apiKey), options).GetChatClient(config.modelName ?? "gemini-2.5-flash").AsIChatClient() // If implementing a custom service, replace "gemini-2.5-flash" with a model from the service
40+
).UseFunctionInvocation().Build(); // UseFunctionInvocation() enables tool calling
4141
}
4242
else
4343
{
@@ -71,15 +71,15 @@ CancellationToken token
7171
{
7272
if (_client == null || _config == null)
7373
{
74-
onError?.Invoke("GeminiChatService is not initialized.");
74+
onError?.Invoke("GeminiChatService is not initialized."); // Any errors should be thrown through the onError callback
7575
return;
7676
}
7777

7878
try
7979
{
8080
var response = await _client.GetResponseAsync(messageHistory, options, token);
8181

82-
onSuccess?.Invoke(new ChatUtils.VoiceBoxChatMessage(response.Messages[0]));
82+
onSuccess?.Invoke(new ChatUtils.VoiceBoxChatMessage(response.Messages[0])); // Return the resulting chat message via the onSuccess callback
8383
}
8484
catch (Exception e)
8585
{
@@ -108,12 +108,13 @@ CancellationToken token
108108
{
109109
try
110110
{
111+
// Send updates as chunks to the onChunkReceived callback
111112
await foreach (ChatResponseUpdate item in _client.GetStreamingResponseAsync(messageHistory, options, token))
112113
{
113114
onChunkReceived?.Invoke(item);
114115
}
115116

116-
onComplete?.Invoke();
117+
onComplete?.Invoke(); // When streaming is finished, invoke the onComplete callback
117118
}
118119
catch (Exception ex)
119120
{

Assets/Scenes/TestScene.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ MonoBehaviour:
153153
m_EditorClassIdentifier:
154154
testSpawnManager: 0
155155
testGUI: 0
156-
testSTT: 1
156+
testSTT: 0
157157
testTTS: 0
158158
testChat: 0
159159
audioSource: {fileID: 2085286909}
@@ -448,7 +448,7 @@ MonoBehaviour:
448448
m_PrefabInstance: {fileID: 0}
449449
m_PrefabAsset: {fileID: 0}
450450
m_GameObject: {fileID: 1493601811}
451-
m_Enabled: 0
451+
m_Enabled: 1
452452
m_EditorHideFlags: 0
453453
m_Script: {fileID: 11500000, guid: 01a5aabf7bb06bc44a509392d6d4c719, type: 3}
454454
m_Name:

Assets/TestTTSManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections;
22
using System.Collections.Generic;
3+
using System.IO;
34
using TimShaw.VoiceBox.Components; // Import useful components from VoiceBox
45
using TimShaw.VoiceBox.Core; // Import core classes from VoiceBox
56
using UnityEngine;
@@ -31,5 +32,7 @@ void Start()
3132

3233
/// Request audio and stream it through the TTS Manager's AudioStreamer
3334
ttsManager.RequestAudioAndStream("Hello World!");
35+
36+
string voiceId = ttsManager.CloneVoiceAndGetVoiceIDAsync(Application.dataPath, "/speechSample.mp3", "VoiceBoxTestVoice").Result;
3437
}
3538
}
Binary file not shown.
6.84 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) .NET Foundation and Contributors
4+
5+
All rights reserved.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## About
2+
Supports the lower-level abstractions for the dependency injection (DI) software design pattern which is a technique for achieving Inversion of Control (IoC) between classes and their dependencies.
3+
4+
## Key Features
5+
- Interfaces for DI implementations which are provided in other packages including `Microsoft.Extensions.DependencyInjection`.
6+
- An implementation of a service collection, which is used to add services to and later retrieve them either directly or through constructor injection.
7+
- Interfaces, attributes and extensions methods to support various DI concepts including specifying a service's lifetime and supporting keyed services.
8+
9+
## How to Use
10+
This package is typically used with an implementation of the DI abstractions, such as `Microsoft.Extensions.DependencyInjection`.
11+
12+
## Main Types
13+
The main types provided by this library are:
14+
* `Microsoft.Extensions.DependencyInjection.ActivatorUtilities`
15+
* `Microsoft.Extensions.DependencyInjection.IServiceCollection`
16+
* `Microsoft.Extensions.DependencyInjection.ServiceCollection`
17+
* `Microsoft.Extensions.DependencyInjection.ServiceCollectionDescriptorExtensions`
18+
* `Microsoft.Extensions.DependencyInjection.ServiceDescriptor`
19+
* `Microsoft.Extensions.DependencyInjection.IServiceProviderFactory<TContainerBuilder>`
20+
21+
## Additional Documentation
22+
* [Conceptual documentation](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection)
23+
* API documentation
24+
- [ActivatorUtilities](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.defaultserviceproviderfactory)
25+
- [ServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.servicecollection)
26+
- [ServiceDescriptor](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor)
27+
28+
## Related Packages
29+
- `Microsoft.Extensions.DependencyInjection`
30+
- `Microsoft.Extensions.Hosting`
31+
- `Microsoft.Extensions.Options`
32+
33+
## Feedback & Contributing
34+
Microsoft.Extensions.DependencyInjection.Abstractions is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime).

0 commit comments

Comments
 (0)