# Change Voice on AI

This script ensures that any unit with the specified classname that spawns during the mission will automatically have its voice changed to the one defined in the script.

{% stepper %}
{% step %}
### Creating a sqf file

Start of by created a **init.sqf** then copy & paste this code in there:

```sqf
[] execVM "SetVoiceOnSpawn.sqf";
```
{% endstep %}

{% step %}
### Creating the script

So now create a new file called **SetVoiceOnSpawn.sqf** open it and paste this code in there:

```sqf
[ "CAManBase", "InitPost", {
	params ["_unit"];
	if (typeOf _unit == "CLASSNAME") then {
		_unit setSpeaker "VOICE"
	};
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
```
{% endstep %}

{% step %}
### Choose unit and voice

Open **SetVoiceOnSpawn.sqf** and find the section labeled `"CLASSNAME"`. Replace `"CLASSNAME"` with the classname of the unit whose voice you want to change.

Next, locate the section labeled `"VOICE"`. Replace `"VOICE"` with the desired voice for the unit. You can refer to the list of available voices under [**Speakers Available**](https://community.bistudio.com/wiki/setSpeaker#Notes) to choose a suitable voice.
{% endstep %}
{% endstepper %}

