# 音声クライアントオブジェクトを初期化する

> How to initialize the Vivox voice client object.

他の Vivox SDK アクションを実行する前に、音声クライアントを作成して初期化する必要があります。音声クライアントの初期化プロセス中、Vivox SDK はさまざまなサブシステムを設定して起動します。これにより追加の共有ライブラリが読み込まれる場合があります。開発者は、Vivox サービスに接続する前にさまざまな Vivox SDK オプションをカスタマイズできます。例えば、開発者は使用可能なコーデック、オーディオダッキングの設定、ログレベルから選択できます。

[`await VivoxService.Instance.InitializeAsync(VivoxConfigurationOptions config)`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_InitializeAsync_Unity_Services_Vivox_VivoxConfigurationOptions_) には、Vivox Core SDK の設定を選択するためのオプションのパラメーターが用意されています。

以下のコードは、Windows、macOS、Android、iOS 上の音声クライアントを作成して初期化する方法の例を示します。

```cs
using System;
using UnityEngine;
using Unity.Services.Authentication;
using Unity.Services.Core;
using Unity.Services.Vivox;

async void Start()
{
    await UnityServices.InitializeAsync();
    await AuthenticationService.Instance.SignInAnonymouslyAsync();

    await VivoxService.Instance.InitializeAsync();
}
```

**重要:** クライアントがすでに初期化されており、アプリケーションが再度そのクライアントの初期化を試行すると、`5041:VxErrorAlreadyInitialized` エラーが発生します。このエラーの詳細については、[Vivox SDK のエラーコード](/vivox-unity/developer-guide/troubleshooting/error-codes.md) を参照してください。

Unity Authentication サービスの詳細については、[Authentication パッケージを使用してサインインする](./sign-in-with-authentication-package.md) を参照してください。代わりの認証方法については、[カスタム ID を使用してサインインする](../../unity/developer-guide/vivox-unity-sdk-basics/sign-in-with-custom-id) を参照してください。または、アプリケーションですでに Vivox アクセストークンを使用している場合は、[VAT と UAS を一緒に使用する](../implement-vivox-unity/integrate-existing-vat-project-with-uas) を参照してください。
